Click to See Complete Forum and Search --> : Uploaded files are not saved!!!


Anon
09-11-2001, 06:13 AM
Hi,

I've just installed Apache, PHP and MySQL on a computer at the uni. I also copied my PHP program that is supposed to help teachers to upload files and share them with students. It worked pretty well on a Linux server, but here the uploaded files are not copied to the directory (eg. c:\Program Files\Apache\htdocs\files) I set the upload_temp_dir (or something like that) in Php.ini to c:\temp but nothing happens. Nothing means that not even an error message is displayed. Weird, isn't it? Can someone with more experience help me? Do I need to make a modification in Php.ini? Please help me! Thanks a lot.

Bye,

Akos David, Hungary

ogge1
09-11-2001, 07:57 AM
Hi!

I looked through my old coding and found the following example i used to upload some certain GIF files to a server running on a WIn98 machine. If you're using WINNT/2K be sure to verify permissions on the folders.

If i understood the manual right, the file is uploaded to TEMP with a temporary name, but it's deleted right after the script has been terminated so you won't see the file there. You have to copy it at once prior to terminating the script.

aswell as making sure that register_globals is set to TRUE in PHP.INI

-------------------
/* The $user_filename is the original filename from the client ie. cucumber.gif
$phbasedir is the basedir where I've put it from the begining. */

$slump = time();
$fl = $phbasedir.$uldir.$slump.$userfile_name;
$picpath = $uldir.$slump.$userfile_name;
copy($userfile, $fl);
$change = "Added picture ".$picpath;
echo "File was copied to the server.";

/* defined variables in my include.php file */

$phbasedir = "C:/apache/htdocs/credit/";
$uldir = "pixs/";
------------------------------

Just let me know if you wan't the full sourcecode.

Anon
09-11-2001, 08:35 AM
Hi Fredrik,

Thanks for your quick reply. So far I haven't changed the directory permissions except c:\...\htdocs\filok where the uploaded files are supposed to be saved. Do I need to change any other directory permission? In Php.ini the upload_temp_dir is set to c:\temp. The problem is that there is no error message. The code just simply doesn't work. It does all the necessary checks.

move_uploaded_file($userfile,"fajlok\$nev") ;

This is the only command that is not executed. $userfile is the original data coming from the form, "fajlok" is the directory I want the files to be saved into (subdirectory of htdocs) and $nev is the new name of the file. Could you please give me further advice?

Thanks,

Akos David, hungary

Anon
09-13-2001, 09:36 PM
Try

move_uploaded_file($userfile,"fajlok/$nev");

Or

move_uploaded_file($userfile,"fajlok\\$nev");

HTH

Dave