jponte Posted April 13, 2010 Share Posted April 13, 2010 Hi, I have a code to upload files to a directory after is created. It works great with small files. After I try uploading a 30Mb file and it dies with the following error: Notice: Undefined index: ticketnumber in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\secure\logs\uploader.php on line 45 Here is my code: <?php $ticket_number = $_POST['ticketnumber']; $target_path = "uploads/$ticket_number/"; $filename = basename($_FILES['uploadedfile']['name']); //Check the form for completion of fields If (!$_POST['ticketnumber']){ echo "<center><b>Error: Please enter a valid ticket number"; }elseif (!$_FILES['uploadedfile']['tmp_name']){ echo "<center><b>Error: Please select the file by clicking on the Browse button"; } else { //If the directory with the ticket number does not exists one is created if (!file_exists($target_path)) { chdir ("D:/"); mkdir("uploads/$ticket_number", 0777); chmod("uploads/", 0777); chmod("uploads/$ticket_number", 0777); } //Check if the file name inside the directory already exists if (file_exists($filename)) { echo "<center><b>There is a file in your same directory already uploaded with the same name, please change the name and try again!</b>"; echo getcwd() . "<br>"; exit(); }else { $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); } //Move the file to the path selected above if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded<br><br>"; echo "Upload: " . $_FILES["uploadedfile"]["name"] . "<br />"; echo "Type: " . $_FILES["uploadedfile"]["type"] . "<br />"; echo "Size: " . ($_FILES["uploadedfile"]["size"] / 1024) . " Kb<br />"; } else{ echo "There was an error uploading the file, please try again!"; echo "If the error persists please contact Rogers ESC at 1-866-939-3282"; } } ?> Any ideas what is happening? Is it a server side problem? This is a windows server. Peace, JP Link to comment https://forums.phpfreaks.com/topic/198412-upload-dying-half-way/ Share on other sites More sharing options...
the182guy Posted April 13, 2010 Share Posted April 13, 2010 Check that these settings in your php.ini are set big enough to cover the upload upload_max_filesize = 50M post_max_size = 50M Link to comment https://forums.phpfreaks.com/topic/198412-upload-dying-half-way/#findComment-1041153 Share on other sites More sharing options...
jponte Posted April 13, 2010 Author Share Posted April 13, 2010 Hi, I changed it to ; Maximum allowed size for uploaded files. upload_max_filesize = 200M ; Maximum size of POST data that PHP will accept. post_max_size = 200M Now my code stops in the middle giving my own error: Error: Please select the file by clicking on the Browse button }elseif (!$_FILES['uploadedfile']['tmp_name']){ echo "<center><b>Error: Please select the file by clicking on the Browse button"; Thanks for your help, JP Link to comment https://forums.phpfreaks.com/topic/198412-upload-dying-half-way/#findComment-1041158 Share on other sites More sharing options...
the182guy Posted April 13, 2010 Share Posted April 13, 2010 Uploaded files have an error property, echo out $_FILES['uploadedfile']['error'] to see if there is an error. The error property should be checked anyway to see if the upload was successful (will be 0 if no error). Link to comment https://forums.phpfreaks.com/topic/198412-upload-dying-half-way/#findComment-1041161 Share on other sites More sharing options...
jponte Posted April 13, 2010 Author Share Posted April 13, 2010 Hi, The error is 2. Where can I check it? Thanks, JP Link to comment https://forums.phpfreaks.com/topic/198412-upload-dying-half-way/#findComment-1041169 Share on other sites More sharing options...
the182guy Posted April 13, 2010 Share Posted April 13, 2010 Code 2 means the file exceeds the MAX_FILE_SIZE setting in the HTML form. Change it so it covers the upload. Error code explanations: http://php.net/manual/en/features.file-upload.errors.php Link to comment https://forums.phpfreaks.com/topic/198412-upload-dying-half-way/#findComment-1041175 Share on other sites More sharing options...
jponte Posted April 13, 2010 Author Share Posted April 13, 2010 Got it.... I just got rid of the line alltogether... Link to comment https://forums.phpfreaks.com/topic/198412-upload-dying-half-way/#findComment-1041178 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.