|
Posted by Rik on 07/13/06 21:07
Chris wrote:
> 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.
The manual states very clearly what it does:
1. it _MOVES_ an uploaded file, (it doesn't COPY!!)
2. it will return false if filename doesn;t exists or cannot be moved, and
true on success
Call me simple, but I don't see very much room fort interpretation here.
> 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?
Euhm, the same function that does the work is the ideal function to return
wether is has succeeded.
Also, the function is move_uploaded_file, not moved_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...
I think it's highly logical that a function that has to perform some action
will return wether it has succeeded or not. Not only logical, I'd hate to
have 2 functions for every action, one to perform it and one te check wether
it has succeeded. Seems illogical to me...
You'd prefer it if for instance mysq_connect wouldn't return anything, so
you'd have to use extra code just to check wether there is a connection to
the database?
> it seems you should:
>
> do move_uploaded file, $target
> check if move is successful (how?)
Why would you want to?
If you don't want to use the function, you could always use
is_uploaded_file(), fopen(), fread(), fwrite(), file_exists(), but why would
you want to go through all that trouble?
> if yes - print success message
> if no - print error message
> end check
Which is done perfectly by;
if(move_uploaded_file($file, $dest){
//success
} else {
//failure
}
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|