I have a webform (6.x-2.9) which includes a (picture) file upload. I have set the max file size allowed to 2mb. When a user attempts to upload a file over 2mb the data is submitted (except for the file) and they get the following error msg on the confirmation page: "The uploaded file was unable to be saved. The destination directory may not be writable."

Am I able to display a more useful message to the user (and hopefully not submit the data until they have corrected their submission)?

Thanks

Phil

Comments

phoenix’s picture

I had the same issue. People mailed to say the got this error message after submitting their form:
"The uploaded file was unable to be saved. The destination directory may not be writable."

I checked and those submission got through, but the photo is missing.

Phil, thanks for reporting this! This saved me some time!

phoenix’s picture

After some more investigation, I see that the filefield has been configured with an upload limit of 800kb. In php the upload_file_size is 2M. Shouldn't there be an error message on submission of a picture that is too big?

phoenix’s picture

Category: support » bug
phoenix’s picture

Category: bug » support

Now I figured it all out.
When a file is selected to upload, it is uploaded during the submission and the filesize is checked. When the limit set for the file component is exceeded an error message is shown to tell the user the picture is too big.
If the upload_max_filesize is too low, the file doesn't get uploaded and you get the weird: "The uploaded file was unable to be saved. The destination directory may not be writable."

This is done in: webform/components/file.inc

$file_saved = file_save_upload($data['new'], array(), $upload_dir);
if (!$file_saved) {
        drupal_set_message(t('The uploaded file %filename was unable to be saved. The destination directory may not be writable.', array('%filename' => $file_saved['filename'])), 'error');
      }

Is there another way to do a filesize check (javascript reading out size and passing it through to validation?). Because even with the upload_max_filesize set to 8M there will always be people trying to upload bigger images... And they will get the weird error message.

Thanks for some help !

dzepol’s picture

Just confirming I also get this error. It took me a little while to figure out why 1/4 of our submissions were missing their files and why no one complained of error (they still got a confirmation email). The form should not submit without the attachment. It would be great if we could customize or alter this message or add a redirect on error.

hefox’s picture

#834254: Upload module tests if file uploads in submit, meaning node is saved but file isn't if file fails validation Similar issue in with core upload; move the uploading to validation then error out if doesn't save should work.

quicksketch’s picture

Status: Active » Closed (fixed)

This is actually a Drupal core bug. See #30520: file_save_upload() not notifying user when PHP upload limit is exceeded.. I'm closing this issue since it hasn't seen any activity in several months.