...

View Full Version : unable to verify if file uploaded using $string = move_uploaded_file()



FreelanceCoder
04-20-2012, 12:51 PM
Can not get this to work. When I echo out the results from the strings, it shows that there is a "1" when the file is uploaded when I comment out the lines with *** in them

But when I use my error checking to see if the file was uploaded ok the code fails.

What could I be doing wrong here, is this the right way to check if uploaded ok using the string ?


$_FILES['files']['name'][$i]=changename($i,$_FILES['files']['type'][$i]);
$newFilename = '/home/jasoncar/public_html/freelisting2/itemImages/'.$_FILES['files']['name'][$i];
$uploadError = move_uploaded_file($_FILES['files']['tmp_name'][$i], $newFilename);
echo("<br>uploaderror<br>:" . $uploadError . ":". $_FILES['files']['name'][$i] . ":<br>");
if ($uploadError == "1") { // ***
$filenames .= $_FILES['files']['name'][$i] . '||';
} else { // ***
$uploadError = "uploadError"; // ***
} // ***

tangoforce
04-20-2012, 03:17 PM
move_uploaded_file() returns a boolean result - that means true or false AKA 1 or 0.

When you try to print this as a string it will print 1 or 0 NOT the words true or false.

It will not return any text such as 'ok', 'failed', 'good', 'bad' etc ONLY 1 or 0.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum