Jump to content

Upload dying half way


jponte

Recommended Posts

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

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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.