Page 1 of 1

uploading a file to the server

Posted: Mon Mar 08, 2004 9:12 am
by nutstretch
I want to upload an image from the users machine to the webserver. The code is saying ok but the file is not uploading.

Please can someone let me know where I am going wrong. It may be i ahve missed out loads of lines of code!!!

(thats women for you!)

<?php
if ($HTTP_POST_FILES['uploadedFile']['size']<=0)
{
print "NO way";
}
else
{
$tempfile = $HTTP_POST_FILES['uploadedFile']['tmp_name'];
$destination = "/gifs/";
copy($tempfile, $destination);
print "OK";
}
?>

I am using php 4.3.3

any help appreciated

Nuts

Posted: Mon Mar 08, 2004 9:37 am
by markl999
Try the example form (and code below) at http://www.php.net/manual/en/features.f ... ost-method and see fit hat works ok for you, then at least you know that uploads in general work ok.

Posted: Mon Mar 08, 2004 11:25 am
by nutstretch
Many thanks I am now getting this error message. It works on my local machine but not when i upload it

Warning: move_uploaded_file(gifs/house.gif): failed to open stream: Permission denied in /home/virtual/site8/fst/var/www/html/dbshoes/savefile.php on line 53

any ideas

Posted: Mon Mar 08, 2004 4:12 pm
by markl999
Looks like /home/virtual/site8/fst/var/www/html/dbshoes/gifs doesn't have sufficient permissions. The user the web server is running as (www, www-data, apache, nobody etc..) needs write permissions on that directory.