solved Custom button not getting any data on post

alt=
@dobmat
10 years ago
93 posts
Hi

I have created a ccustom upload button to upload files. In the upload form I have only files filed. When I try this in my upload_save funtion,

jrCore_form_get_save_data('gsVenue', 'upload', $_post);

I'm getting an empty array. I'm not sure why this is happening.

Thanks.
updated by @dobmat: 07/09/14 01:49:25AM
brian
@brian
10 years ago
10,148 posts
If it is only a file upload, then you're not going to get anything in $_post. $_post is for "normal" form fields.

you will need to use the jrCore_get_uploaded_media_files() function if you want to see what files were uploaded - i.e.

$_im = jrCore_get_uploaded_media_files('yourModule', 'module_file', $_user['user_active_profile_id']);

and then jrCore_save_all_media_files() to save then files to the proper profile location - i.e.

jrCore_save_all_media_files('yourModule', 'create', $_user['user_active_profile_id'], $id);

Where in this case $id is the unique datastore item_id for the created item (it must be created first, then you handle the file uploads).

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
alt=
@dobmat
10 years ago
93 posts
Thanks for the guidance. I've tried as you suggested. I'm getting an error "You forgot to select a file to upload". My code is as below,

$_files = jrCore_get_uploaded_media_files('gsVenue', 'venue_files', $_user['user_active_profile_id']);
if (isset($_files) && is_array($_files)) {

$_up['venue_order'] = $ord;
foreach ($_files as $file_name) {
$_up['venue_order']++;
$aid = jrCore_db_create_item('gsVenue', $_up);
if (!$aid) {
jrCore_set_form_notice('error', 7);
jrCore_form_result();
}

jrCore_save_media_file('gsVenue', $file_name, $_user['user_active_profile_id'], $aid);

if (!isset($action_saved)) {
jrCore_run_module_function('jrAction_save', 'upload', 'gsVenue', $aid);
$action_saved = true;
}
}
}

Thanks.
SteveX
SteveX
@ultrajam
10 years ago
2,584 posts
jrCore_save_all_media_files('gsVenue', 'create', $_user['user_active_profile_id'], $aid);


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
alt=
@dobmat
10 years ago
93 posts
Thanks a lot. It is working for me now.

Tags