Uploading files via PHP, but upload_tmp_dir has no value.

Oct 19, 2000
17,860
4
81
I'm trying to upload a file via PHP, and I'm getting errors when trying to copy it from the temp directory to a permanant one. Everything else works fine, I just can't get it to copy.

When running phpinfo(), I see that the upload_tmp_dir is set to no value. However, I've read elsewhere previously that stated this having no value was typically only a problem when running on Windows. My _SERVER["PATH"] shows as /bin:/usr/bin, I'm assuming that's some kind of *nix variant, correct?

I've also modified permissions on the folder to 777 that I'm trying to move the file to.

Can anyone give me some tips to help me get moving in the right direction to figure this out? Should the upload_tmp_dir be changed to a definite value, and if so, is that typically something you request of the webhost? I appreciate any help.
 

Hyperblaze

Lifer
May 31, 2001
10,027
1
81
What happens when you do

var_dump($_FILES);

edit: And I'm talking about the post page here.
 
Oct 19, 2000
17,860
4
81
Originally posted by: Hyperblaze
What happens when you do

var_dump($_FILES);

edit: And I'm talking about the post page here.

array(1) { ["picturesubmit"]=> array(5) { ["name"]=> string(25) "0608pariscarcryinffo1.jpg" ["type"]=> string(11) "image/pjpeg" ["tmp_name"]=> string(14) "/tmp/phpNoQH1g" ["error"]=> int(0) ["size"]=> int(180904) } }
 

Hyperblaze

Lifer
May 31, 2001
10,027
1
81
Originally posted by: blurredvision
Originally posted by: Hyperblaze
What happens when you do

var_dump($_FILES);

edit: And I'm talking about the post page here.

array(1) { ["picturesubmit"]=> array(5) { ["name"]=> string(25) "0608pariscarcryinffo1.jpg" ["type"]=> string(11) "image/pjpeg" ["tmp_name"]=> string(14) "/tmp/phpNoQH1g" ["error"]=> int(0) ["size"]=> int(180904) } }

move_file_uploaded is the function I'd use to move it to the correct location.

What functions are you trying to use?
 
Oct 19, 2000
17,860
4
81
if($_FILES['picturesubmit']!="") {
$fileName = $_FILES['picturesubmit']['name'];
$tmpName = $_FILES['picturesubmit']['tmp_name'];
$fileSize = $_FILES['picturesubmit']['size'];
$fileType = $_FILES['picturesubmit']['type'];
$filePath = $uploadDir . $fileName;
$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "<b>Error uploading file. Please try adding the picture later.</b><br /><br />";
var_dump($_FILES);
}

if(!get_magic_quotes_gpc()) {
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
}
 
Oct 19, 2000
17,860
4
81
Originally posted by: tfinch2
Originally posted by: Hyperblaze
what's $filePath defined as?

$filePath = $uploadDir . $fileName;

The question should be what is $uploadDir set to?

$uploadDir = '/uploads/pictures/';

These folders have already been created and waiting.
 
Oct 19, 2000
17,860
4
81
Any ideas?

You know what, scratch that, I just figured out what it was. I needed to take out that slash from the beginning of the $uploadDir variable, and now it works fine.
 

Hyperblaze

Lifer
May 31, 2001
10,027
1
81
From what you had written in your last post, I couldn't quite figure out what was wrong. Glad you got it figured out. I wasn't aware of your environment so it was impossible for me to know /uploads/ was a subdirectory.

Last thing I wanted to write was "I have no idea",