Uploading files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Uploading files

Post by spacebiscuit »

Hi guys,

I am trying to enable users to upload files via a HTML form. This is the code I am using but I am receiving an error message when the user submits:

Code: Select all

$root="$_SERVER[DOCUMENT_ROOT]/available";
$dir="/";
                  
$target_path_image=$root . $dir . 'image' . $dir;
$target_path_image=$target_path_image . basename( $_FILES['uploadedimage']['name']); 
 
if(move_uploaded_file($_FILES['uploadedimage']['tmp_name'], $target_path_image)){
                                  
     echo "The main image and pdf have been successfully uploaded";
                                                                                                                            } 
 
else{
    echo "There was an error uploading the files, please try again!";
      }
Is there anything bviously wrong, or else how can I output the error?

Thanks in advance,

Rob.
wellhole
Forum Newbie
Posts: 16
Joined: Mon Mar 23, 2009 1:38 pm

Re: Uploading files

Post by wellhole »

I'm guessing its a permissions problem.

Here's some error handling that doesn't deal with permissions. Try it out first. http://www.htmlgoodies.com/beyond/php/a ... hp/3472561
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Uploading files

Post by spacebiscuit »

I think I figured the problem, does the the form method have to be "POST"?

I had it set to GET - I think the $_FILES only work with POST.

Thanks,

Rob.
Post Reply