0

On my XAMPP server, copy() and move_uploaded_file() fail to work if any file uploaded via http request is over 30kB even thought the php.ini post_max_size and upload_max_size values are well over 30kB.

$tmpfile = $_FILES['fileupload']['tmp_name'];
$fileExtension = 'txt';
$newfilename = '01234';

if (!move_uploaded_file($tmpfile, "files/" . $newfilename . "." . $fileExtension)) {
echo "Failed to upload.";
} else {
echo 'Uploaded successfully.';
}

And the php.ini looks like:

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize=70M

; Maximum number of files that can be uploaded via a single request
max_file_uploads=20

; Post form size limit
post_max_size=80M

I can't see what I'm doing wrong here, does anyone know how to fix this?

  • 1
    did you restart your Apache server after updating php.ini file ? – Halayem Anis Feb 16 '15 at 09:31
  • 1
    You can check the effective settings e.g. via `foreach( array('cfg_file_path', 'upload_max_filesize', 'max_file_uploads', 'post_max_size') as $p ) { printf("%s - cfg:'%s' , ini:'%s'
    \r\n", $p, get_cfg_var($p), ini_get($p)); }` and also check whether you have something like suhosin installed - it has additional settings to limit the in/output.
    – VolkerK Feb 16 '15 at 09:35
  • possible duplicate of [PHP change the maximum upload file size](http://stackoverflow.com/questions/2184513/php-change-the-maximum-upload-file-size) – CBroe Feb 16 '15 at 11:20

0 Answers0