0
<?php
if($_POST['uae']){
 move_uploaded_file($_FILES["file"]["tmp_name"], FS_DOC_ROOT . 'uploads/' . urlencode($_FILES['file']["name"]));
 mail("email@address","Uploaded File for you",$_POST['message']."\n\nTo view the file please follow the following link: ".HTTP_SERVER."uploads/".urlencode($_FILES['file']['name']).".","FROM: DONOTREPLY <do-not-reply@website.com>");
 echo "<div style='background: green;color: #ffffff;padding: 5px;'>All sent... send another one below.</div>";
}
?>

<form method="post" action="uploadandemail.html" enctype="multipart/form-data">

 <table>
     <tr>
         <td>Choose a file to upload:</td>
            <td><input type="file" name="file" /></td>
        </tr>
        <tr>
         <td valign="top">Message:</td>
            <td><textarea name="message" cols="40" rows="40" style="height: 150px;">I have uploaded a file for you.</textarea><br />This will be superceeded with "To view the file please follow the following link: http://linktoyour.new/file.doc".</td>
        </tr>
        <tr>
         <td></td>
            <td><input type="submit" name="uae" value="Upload and Email" /></td>
        </tr>
    </table>

</form>

It doesn't work - it will quite happily upload a small image or a PDF but it don't upload an mp4 or an mpeg. It doesn't even try it, the page just refreshes straight away.

Any ideas? php.ini is set to 100M max upload.

This is my php5.ini file:

error_reporting  =  E_ALL
upload_max_filesize = 100M

Thanks

Thomas Clayson
  • 29,657
  • 26
  • 147
  • 224
  • Maybe max_execution_time isn't enough? – fabrik Oct 15 '10 at 11:28
  • you should check also the settings for max_input_time and post_max_size – Dr.Molle Oct 15 '10 at 11:33
  • pleas tell me that your not uploading files without any kind of validation ... – teemitzitrone Oct 15 '10 at 11:50
  • @maggie - at the moment, because its not uploading mpegs... so I stripped it down... can't get it to work like this, then its not the validation thats stopping it. – Thomas Clayson Oct 15 '10 at 12:06
  • phew ok, turn on `error_reporting(E_ALL); ini_set('display_errors','on');` dump `$_FILES` array. check your php.ini settings `phpinfo()`. read http://www.php.net/manual/en/ini.core.php#ini.post-max-size for details – teemitzitrone Oct 15 '10 at 12:48
  • keep in mind `memory_limit` > `post_max_size` > `upload_max_filesize` and of course don't forget `max_execution_time` http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time – teemitzitrone Oct 15 '10 at 12:52

2 Answers2

1

There must be a default in MAX_FILE_SIZE that is too low for the big file. While MAX_FILE_SIZE can be fooled, as the php.net site points out, it's a convenience so a user doesn't wait out a long upload only to find the file is too big because of a php.ini setting

From: http://www.php.net/manual/en/features.file-upload.post-method.php

The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file input field, and its value is the maximum filesize accepted by PHP. This form element should always be used as it saves users the trouble of waiting for a big file being transferred only to find that it was too large and the transfer failed. Keep in mind: fooling this setting on the browser side is quite easy, so never rely on files with a greater size being blocked by this feature. It is merely a convenience feature for users on the client side of the application. The PHP settings (on the server side) for maximum-size, however, cannot be fooled.

Hans
  • 3,403
  • 3
  • 28
  • 33
1

my ini settings

memory_limit: 1G
post_max_size: 400M
upload_max_filesize: 100M

max_execution_time: 450

(test) File-size: ~31MB

$_FILES dump

Array
(
    [userfile] => Array
        (
            [name] => Adium.app.zip
            [type] => application/zip
            [tmp_name] => /private/tmp/phpuuG0VK
            [error] => 0
            [size] => 33300224
        )

)
teemitzitrone
  • 2,250
  • 17
  • 15
  • that was ~ the same as mine. :) it was the lack of 0s in my MAX_FILE_SIZE hidden field. Thank you very much for your help. :) – Thomas Clayson Oct 15 '10 at 13:29