uploading a file to the server

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
nutstretch
Forum Contributor
Posts: 104
Joined: Sun Jan 11, 2004 11:46 am
Location: Leicester

uploading a file to the server

Post 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
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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.
nutstretch
Forum Contributor
Posts: 104
Joined: Sun Jan 11, 2004 11:46 am
Location: Leicester

Post 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
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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.
Post Reply