Forum Moderators: coopster
<?php
move_uploaded_file($_FILES['Filedata']['tmp_name'], "./files/".$_FILES['Filedata']['name']);
?>
Simple one liner, it just makes the file. The problem is, with large files it seems to throw a HTTP 500 Internal Server Error and die rather hideously.
Any ideas?
Have you looked in your logs to see if there is another error getting put in there by php? Or to see if there is any more info on what is killing the server?
It has also occurred to me that if you still have an active file handle then that file may well be locked. So have you closed all of your file handles before you are trying to move that file?
For example -
$fh = fopen('somefile.txt', 'r');
move_uploaded_file('somefile.txt', 'somefile1.txt');
// may well fail, as $fh may well be locking somefile.txt
$fh = fopen('somefile.txt., 'r');
fclose($fh);
move_uploaded_file('somefile.txt', 'somefile1.txt');
// should work as there is no lock on somefile.txt
You may also want to check out rename [uk.php.net] just in case the 500 error is just a random problem with move_uploaded_file function.
php_value upload_max_filesize 20M
php_value post_max_size 20M
# php_value followed by whatever directive you want to alter.
If that doesnt work then there is a sneaky way to get around it if you have shell access to the server...although if you use this then you will annoy your host so be prepared.
If the htaccess doesnt work and you have shell access then come back and I'll let you know (but dont blame me when you get a kicking from your provider).
If you search for 'increasing max file size php.ini shell access' on the web then you will come across a few articles that tel you how to alter php.ini if you have shell access...so then you can find them and not blame me when you get a kicking from your provider ;)