|
Posted by Chris on 07/13/06 16:54
Hi Rik,
I have to grin because every time somebody says "Look at the manual", I have
already done so, and the manual isn't clear.
I get the 'if' part and returning false, which would be used to confirm if
the file was moved, right? Then you would perform some operation based on
the true or false return value. What isn't clear is what 'command' actually
moves the uploaded file? Then I would want to confirm 'if' the file was
moved, and if not, print the error message. What the references look like to
me is that it is moving the file at the same time it is checking if it was
moved. This just looks illogical...it seems you should:
do move_uploaded file, $target
check if move is successful (how?)
if yes - print success message
if no - print error message
end check
Thanks,
Chris
>
> Look at the manuel:
> If filename is not a valid upload file, then no action will occur, and
> move_uploaded_file() will return FALSE.
>
> If filename is a valid upload file, but cannot be moved for some reason,
> no
> action will occur, and move_uploaded_file() will return FALSE.
> Additionally,
> a warning will be issued.
>
> So,
>
> if(move_uploaded_file($tmp,$target)){
> //will execute code on succes: succesfull upload & move.
> } else {
> //error with moving or uploading
> }
>
> The following will work, but more verbose:
>
> $checkj = move_uploaded_file($tmp,$target);
> if($check){
> //will execute code on succes: succesfull upload & move.
> } else {
> //error with moving or uploading
> }
>
> The following will not work, because the file already has been moved:
> move_uploaded_file($tmp,$target); //this works
> if(move_uploaded_file($tmp,$target)){ // this returns false: the file has
> already been moved
> //will execute code on succes: succesfull upload & move.
> } else {
> //error with moving or uploading
> }
>
> Grtz,
> --
> Rik Wasmus
>
>
Navigation:
[Reply to this message]
|