Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2012
    Thanked 1 Time in 1 Post

    unable to verify if file uploaded using $string = move_uploaded_file()

    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 ?
    $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";	//		***
    			}	//		***

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Your Monitor
    Thanked 537 Times in 524 Posts
    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.
    I can't really think of anything to write here now...


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts