Jump to content

Multiple File Upload Issue


learningPHP1

Recommended Posts

Hello,

 

PHP file upload script.

 

Problem: Unable to upload file under ubuntu server.

 

I have 2 different webservers setup:

1. xampp on usb and my problametic script works.

2. ubuntu server, exact same php script but it wont upload the file.

 

What i noticed with xampp: <--works

echo "<br>tempFile=>:-". $_FILES['data']['tmp_name'][$x] . "<br>";

result: tempFile=>:-G:\xampp\tmp\php2D.tmp

print_r($imagearray);

Array ( [0] => Array ( [1] => G:\xampp\tmp\php2D.tmp [2] => 1357153942_robinuser_dog.jpg ) )

 

What i noticed with Ubuntu server:

echo "<br>tempFile=>:-". $_FILES['data']['tmp_name'][$x] . "<br>";

tempFile=>:/tmp/phpzN6e8U <-- looks like the "tmp" extention is missing.

print_r($imagearray);

Array ( [0] => Array ( [1] => /tmp/phpzN6e8U [2] => 1357153182_robinuser_bird.jpg ) )

 

if the temp file ext is missing how do I fix this??

 

Any help you can provide would be greatly appreciated

 

if(isset($_POST['action'])=='uploadfiles')
{ for($x=0; $x<count($allowedUpload); $x++)
{ echo "<br>tempFile=>:-". $_FILES['data']['tmp_name'][$x] . "<br>";
if(!empty($_FILES['data']['name'][$x]))
{ $extension = end(explode(".", $_FILES['data']['name'][$x]));
if ((($_FILES["data"]["type"][$x] == "image/gif")
 || ($_FILES["data"]["type"][$x] == "image/jpeg")
 || ($_FILES["data"]["type"][$x] == "image/png")
 || ($_FILES["data"]["type"][$x] == "image/pjpeg"))
 && ($_FILES["data"]["size"][$x] < $fileSize)
 && in_array($extension, $allowedExts))
{ if ($_FILES["data"]["error"][$x] > 0)
 { echo "Error: " . $_FILES["data"]["error"][$x] . "<br>"; }
 else
 { //Sanitize the filename
 $sanitizedName = str_replace($remove_these, '', $_FILES['data']['name'][$x]);
 $newImageName = time()."_".$imageUserId."_".$sanitizedName;
 //move_uploaded_file($_FILES['data']['tmp_name'][$x], $upload_directory . $newImageName);
 if(!empty($newImageName))
 { $imagearray[$x][1] = $_FILES['data']['tmp_name'][$x];
 $imagearray[$x][2] = $newImageName;
 }	
 }
}
else
{ echo "Invalid file: ".$_FILES["data"]["name"][$x]; }
}// end of IF- if(!empty($_FILES['data']['name'][$x]))
} // endo for loop
print_r($imagearray);
for($y=0; $y< count($imagearray); $y++)
{ move_uploaded_file($imagearray[$y][1], $upload_directory . $imagearray[$y][2]);
echo $imagearray[$y][1] . " " .$upload_directory . $imagearray[$y][2]."<br>";
}	
} // end of upload button

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.