|
Posted by Chris on 07/13/06 21:41
My goodness Rik, you certainly are sensitive...are you one of the writers of
the manual? Some of us don't have years of PHP programming behind us. I
certainly don't, I have only used VB, Perl, Javascript, and similar
scripting.
> The manual states very clearly what it does:
> 1. it _MOVES_ an uploaded file, (it doesn't COPY!!)
actually, in some references I've seen it says it does copy the file to the
final destination, then deletes the temp file.
> 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.
>
interestingly though - using exactly the example from the manual on 2
different servers - it doesn't work for me. Perhaps it's a server issue.
File uploads is on in both php.ini files as well as a temp directory
defined.
>
> 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.
That was a typo - as everyone makes - including you (see below at
"mysq_connect" and above at "much room fort" and "wether").
> 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?
>
I simply was stating that it didn't make sense to ask if a function worked
BEFORE you initiated the function.
With mysql_connect you don't encapsulate it within an 'if' statement - you
simply write the command.
Imagine encapsulating an echo statement:
<?php if (echo "Hello World"){
print "congratulations";
}else{
print "sorry, dude";
}?>
>
> 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]
|