Hi, I am having problems with a file upload. Basically i am trying to upload a file using php. My problem lies when i try and upload a file bigger than 500kb the script times out as soon as the form is submitted. I have check the upload limit on the server and this is set to 2meg so there should not be a problem there. move_uploaded_file($_FILES['file']['tmp_name'], './files/'.$_FILES["file"]["name"]); $db = file('./data.db'); $lastid = 0; foreach ($db AS $d) { list($id, $user) = explode('|', $d); $lastid = $id; } $db = implode("",file('./data.db')); $fh = fopen('./data.db', "w"); $username = $_POST["username"]; $title = $_POST["title"]; $description = $_POST["description"]; $filename = $_FILES["file"]["name"]; fwrite($fh, $db.($lastid+1)."|".$username."|".$title."|".$description."|".$filename."|\n"); fclose($fh); Code (markup): Any ideas anyone? Cheers, Adam
Check the following values from your php.ini: upload_max_filesize, post_max_size, max_input_time. Additional info here: http://www.php.net/features.file-upload
max_input_time = 60 is a little low for a post_max_size of 8M. I don't know if that's the problem though. I'm not sure what you mean when you say the script times out as soon as the form is submitted. If it is timing out because of the max_input_time setting, that would take 60 seconds.
The script won't be executed until the file is sent to the server. And the moving shouldn't take a second once it's uploaded. So there must be another reason for the time out. Can you post your code so I can try it?
This is the form that submits to the php page: <form method="post" action="file.php?add=file" enctype="multipart/form-data"> <p class="style1"><b>Username: </b><select name="username"> <?php $unames = file("files/usernames.php"); foreach($unames AS $line) { list($user, $spare1, $spare2) = explode('|', $line); print "<option>$user"; } ?> </select> <b>File: </b><input type="file" name="file"><br /><b>Title: </b><input type="text" name="title"> <br> <strong>Description:</strong><br /> <textarea style="width: 100%;" rows="4" name="description">Description of this file</textarea> <input type="submit" value="Add File"></p></form> Code (markup): Then this is the php form: move_uploaded_file($_FILES['file']['tmp_name'], './files/'.$_FILES["file"]["name"]); $db = file('./data.db'); $lastid = 0; foreach ($db AS $d) { list($id, $user) = explode('|', $d); $lastid = $id; } $db = implode("",file('./data.db')); $fh = fopen('./data.db', "w"); $username = $_POST["username"]; $title = $_POST["title"]; $description = $_POST["description"]; $filename = $_FILES["file"]["name"]; fwrite($fh, $db.($lastid+1)."|".$username."|".$title."|".$description."|".$filename."|\n"); fclose($fh); Code (markup): Any ideas?