PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a file upload script which works fine with smaller files but when I try to upload some bigger files it fails. and I mean as a smaller files some less than one MB files and with big I mean about 10MB files. here's the code:
if($submit)
{
$uploaddir = '../files/';
$uploadfile = $uploaddir. $_FILES['userfile']['name'];
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
{
echo "<script>alert('the file upload completed succesfully');</script>";
redirect('files_add.php?filename='.$_FILES['userfile']['name']);
}
else
{
echo "<script>alert('the file upload did NOT succeeded');history.go(-1);</script>";
}
}
else
{
echo "
<br>
<form action="files_upload.php" method="post" enctype="multipart/form-data">
<table width="75%" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>
This is the first step of file adding process. In this step you will upload your file into our webhost.
Do not add any material which has copyright or violates any
laws. Do not also add large files (tens of MBs) without the agreement of clan leader.<br><br>
</td>
</tr>
<tr>
<td>
<input type="file" name="userfile">
<input type="hidden" name="MAX_FILE_SIZE" value="200000000">
<input type="submit" value="upload the file" name="submit">
</td>
</tr>
</table>
</form>
";
}
can someone please tell me what's wrong with that if you know.
i think your script run into a time out error or your vars does not allow such big files.
check the values of file_uploads, upload_max_filesize, upload_tmp_dir and post_max_size in the php.ini file.
furthermore set your script-timeout to zero. check ini_set() for more information.
but it still doesn't work. I think I may have an error in my syntax there but I couldn't find an example anywhere so correct it if it's wrong and tell me how can I can bypass it.