PHP upload issues (works on one site, not another)

software development


Hi guys!

I have two websites on Dreamhost. One is mine, and the other is my friend’s, whose website I am programming for him. He just registered a few days ago, so before that I was doing all the development on my host. Now with the exception of the database name that I’m saving the image file path locations and some other data to, the scripts are IDENTICAL. But only the one on my development site works!

The broken one (hosted on Whittier):

The working one (hosted on Grant):

Before you jump to any conclusions though,

  1. All directories have the same permission settings
  2. Both domains have PHP running as CGI
  3. I’ve already tried renaming the jpeg MIME type to pjpeg with no success

So aside from the machines that are hosting the sites, I can see NO DIFFERENCE between the two. The form upload scripts are the same as well (portfolio.php)

What I am noticing, is that I can’t echo out a [‘tmp_file’] of the broken page, so I don’t know what that could mean other than the file isn’t being uploaded, but I don’t know why it wouldn’t be.

Please help!

portfolio.php (The form)

Main Image (< 385):
Thumbnail Image (10x10):
Category: Photo Poster

upload.php (The processing script)
Note: functions and database info removed from script

$imageOriginal = $_FILES[‘imageFile’][‘tmp_name’];
$thumbOld = $_FILES[‘thumbFile’][‘tmp_name’];
$imageNew = ‘…/images/’ . $_FILES[‘imageFile’][‘name’];
$thumbNew = ‘…/thumbs/’ . $_FILES[‘thumbFile’][‘name’];
$category = $_POST[‘category’];
$description = stripslashes($_POST[‘desc’]);
$altText = stripslashes($_POST[‘altText’]);

// Check whether or not the file uploaded is a JPEG
if ($_FILES[‘imageFile’][‘type’] == “image/jpeg” && $_FILES[‘thumbFile’][‘type’] == “image/jpeg”) {

// Get the dimensions of the the uploaded image
$imageDimensions = getimagesize("$imageOriginal");
$imageWidth = $imageDimensions[0];
$imageHeight = $imageDimensions[1];

// If one of the dimensions is greater than 343, then resize the image
if($imageWidth > 343) {
$reductionFactor = $imageWidth / 343;
$newWidth = 343;
$newHeight = $imageHeight / $reductionFactor;
resizeToFile($imageOriginal, $newWidth, $newHeight, $imageNew);
rename($thumbOld, $thumbNew);
addToDatabase($category, $_FILES[‘thumbFile’][‘name’], $_FILES[‘imageFile’][‘name’], $description, $altText, $newHeight, $newWidth);
} else if($imageHeight > 343) {
$reductionFactor = $imageHeight / 343;
$newWidth = $imageWidth / $reductionFactor;
$newHeight = 343;
resizeToFile($imageOriginal, $newWidth, $newHeight, $imageNew);
rename($thumbOld, $thumbNew);
addToDatabase($category, $_FILES[‘thumbFile’][‘name’], $_FILES[‘imageFile’][‘name’], $description, $altText, $newHeight, $newWidth);
} else {
rename($imageOriginal, $imageNew);
rename($thumbOld, $thumbNew);
addToDatabase($category, $_FILES[‘thumbFile’][‘name’], $_FILES[‘imageFile’][‘name’], $description, $altText, $newHeight, $newWidth);
} else {
die(“One or more of your files was not a JPEG. Please upload JPEG files only!”);


Ok I just tried echoing out the size and I’m getting 0, so it looks like the file isn’t being transferred. Any takers? Please!


Are you using a different MySql database/hostname for each script? The only thing I can think of is that they have not been created yet.
I was going to upload a test image to see if it might be a local browser cache problem, but I did not know if your scripts were live, so I did not. :slight_smile:



well, even if i comment out any of the mysql code and only try and echo out the tmp_name I get nothing or size and I get 0. in the php documentation, it says:

“If no file is selected for upload in your form, PHP will return $_FILES[‘userfile’][‘size’] as 0, and $_FILES[‘userfile’][‘tmp_name’] as none.”

So I’m completely stumped, because I’m definately selecting a file in my form.


I got an error of “6” which states:

“Value: 6; Missing a temporary folder”

So…how do I create a temporary folder?


my temp directory wasn’t working because dreamhost didn’t change a permission setting when they upgraded something.