file uploading with move_uploaded_file()
Posted on 2004-03-24
I just recently moved my web site to a new server. The new server does not support passing variables from page to page automatically. I now have to modify my scripts to pull in the variables using $_POST and $_GET (something i've never had to do, what a pain in the @$$!!!)
Before, I was able to use: copy("$pic", "/dir/tmp/blah/www/$pic_name"); (so easy!!)
But now I'm having a hell of a time trying to get it to work with $_FILES.
I've been told that I can't get the "full path" of the file on the user's computer with $_FILES, IE: "c:/blah/blah/blah/filename.gif" .. because it makes a security hole? Seems like if I could get the full path, like i used to, I could just use copy() again and everything would work fine, but no!! hehe.
So.... I've read the manual at php for "handling file uploads" ..... From what I've read, instead of using copy(), I now have to use move_uploaded_file()... something like this:
$uploaddir = '/my/unix/server/address/www/';
$uploadfile = $uploaddir . $_FILES['pic']['name'];
But that doesn't seem to work. What am I missing? Thanks for any help in advance.