开发者

Why dosen't this upload script work with mp4s, mpegs (and maybe any /large/ files)?

开发者 https://www.devze.com 2023-01-20 06:36 出处:网络
<?php if($_POST[\'uae\']){ move_uploaded_file($_FILES[\"file\"][\"tmp_name\"], FS_DOC_ROOT . \'uploads/\' . urlencode($_FILES[\'file\'][\"name\"]));
<?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>
开发者_C百科            <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


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.


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
        )

)
0

精彩评论

暂无评论...
验证码 换一张
取 消