I've been beating myself up on this issue all week. This is my first time using file uploads in custom modules so I'm using managed_file.
Here's a snippet of it that's being used:
$form['family_fid'] = array(
'#type' => 'managed_file',
'#title' => t('Family photo'),
'#description' => t('Upload a family photo, allowed extensions: jpg, jpeg, png, gif'),
'#upload_location' => 'public://families/',
'#upload_validators' => array(
'file_validate_extensions' => array('png gif jpg jpeg'),
),
);
The file upload works fine but the 'throbbing' ajax indicator never finishes and the customer is not happy. Looking around on SO I see that I must:
pecl install uploadprogress
And I have locally. Drupal in /admin/reports/status reports:
Upload progress Enabled (PECL uploadprogress)
No change, even after restarting apache 2.4 on ubuntu. The bad thing is that this project needs to go to Dreamhost shared hosting so I cannot install using PECL. They do point to where I can add "extension = uploadprogrevs" to my .phprc and I have. They have restarted but Drupal on DH does not see it. (FIXED: see edit) Regardless, I have to get some notification to the user that the file upload was successful.
Looking at file_managed_file_submit it describes the function doing a $form_state['rebuild'] at the end, which is ideal. But I don't get that. I don't want to hack a core function so asking around we tried a hook_file_presave($file):
function calendar_admin_file_presave($file) {
drupal_set_message('File uploaded');
}
But no message at any point, esp. when user clicks "Upload". We have tried hook_file_insert and it doesn't seem to work.
We have tried adding #process to the form array:
'#process'=>array('file_managed_file_process','_custom_file_process'),
with this functions:
function _custom_file_process(&$element,&$form_state){
if ($form_state['values']['family_fid']['fid']){
module_invoke_all('file_presave', $file);
}
with no different result.
To further troubleshoot this drupal 7 app I set up a custom content type with a file field. It exhibits this same behavior locally. However, another Drupal 7 app on the same local server, same php 5.4.33 works as expected.
Even if I could get it to work on this app locally, I still will have an issue with Dreamhost shared server. So if I can get a notification to be done when a file is uploaded, I'd be OK. However it seems that Drupal in this app #uploadprogress is not working.
What else can I try to at least get a drupal_set_message inserted? thx, sam
One part of this is to get the PHP extension uploadprogress installed on Dreamhost and that is successful. Either we figure out why the drupal "callback" functions aren't working, or we can determine what could be causing this drupal 7 app to break this AJAX update when other Drupal apps on the same server don't have this issue?