I am struggling with a file upload form that isn't working. So I tried the default form that Drupal presents when I navigate to node/add/upload and that also isn't working so I think the problem isn't with my code but with the uploading in general. They both have the same behavior...I am able to choose a file but when I click on the submit button, the browser says it is loading but it just spins and spins and spins...
I do have the Drupal core Upload and CCK FileField modules enabled and permission for this user's role to create upload content.
Also, I have the form validate and submit functions with a print statement but it never seems to get to either one.
Does anyone know what the problem is or how I can debug this?
All help is greatly appreciated!
Mona
Comments
Working for user #1
Upon further debugging, both the default and my upload forms work for user #1 but not for the other user. I am not sure what I need to do as the other user has permission to create and edit upload content...what other permission setting is needed?
Browser issues
Ok, upon more testing, it appears to be a browser-related issue.
On Safari, the upload just spins and spins and spins for both user #1 and other users and for both default and code generated forms.
On Firefox, after clicking the upload/submit button, I get an error that says the file is required...so it thinks the file is missing, but I did choose a file. This is the same for both user #1 and other users.
So it appears to be a browser-specific issue...
So, after all this, anyone can help me figure out why on Firefox after I click submit, it complains that the file is missing when I did include one?
Back to form not working
Well, I'm back to my original problem on the Firefox browser.
I can upload a file successfully using the default form (node/add/upload).
But my code generated upload form doesn't work. It gives me a missing file error...when I give it the same file that I use for the default form. Now, it does go to the form validate function and a check of the form_state says the file field is indeed empty.
My simplified file upload form is:
$form['#attributes']['enctype'] = 'multipart/form-data';$form['file'] = array (
'#type' => 'file',
'#description' => 'We accept .zip, .tgz and .gz files',
'#required' => TRUE,
'#title' => t ( 'Choose your file to upload' ) );
$form['submit'] = array ( '#type' => 'submit', '#value' => 'Submit' );
return ( $form );
Any help or suggestion is appreciated. I'm at my wits end...
Mona
Trying form alter
So I thought I would try the form alter function and all I have is an empty function:
function mmil_upload_form_alter ( &$form, $form_state )
{
}
and that gives me the same problem! It tells me the file field is missing, when I did give it a file...
Maybe time for me to quit...
Required is not applicable
Required is not applicable with 'file' type. Remove it!