On Thu, 22 Apr 2004 22:03:58 GMT, Pygar <pygarspamcop.net> wrote:
Actually I don't know off the top of my head what happens now. You have a>"mmsnork" <nospam9comcast.net> wrote:
>>>>Why does #1 below works but not #2? The only difference is that I'm calling
>>move_uploaded_file() from within a function. Thanks in advance.
>> $dest = "./images/";
>> $dest = $dest . $_FILES['userfile']['name'] ;
>> move_uploaded_file($_FILES['userfile']['tmp_name'], $dest) ;
>I believe in #2 you need to add one line:
>> global $dest;>>#2:
local paramter named $dest, and you've just used global $dest. I presume this
brings the global $dest into scope and hides the local parameter? Which
wouldn't be what the OP wants at all in #2, since there isn't a global $dest.
In #1 you use $_FILES['userfile']['tmp_name'].>> $dest = "$dest" . $_FILES['userfile']['name'] ;
>> move_uploaded_file($_FILES['userfile']['name'], $dest);
In #2 you use $_FILES['userfile']['name'].
move_uploaded_file requires the 'tmp_name', not the 'name'.
The OP was already passing the value as a parameter properly, rather than>>>}
>>$destDir = "./images/";
>In order to "pass" a value, you may have to declare it as a global.
"passing" it through a global.
Andy Hassall <andyandyh.co.uk> / Space: disk usage ysis tool
[url]http://www.andyh.co.uk[/url] / [url]http://www.andyhsoftware.co.uk/space[/url]