Page 1 of 1

Uploading files

Posted: Tue Mar 24, 2009 11:42 am
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.

Re: Uploading files

Posted: Tue Mar 24, 2009 12:32 pm
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

Re: Uploading files

Posted: Tue Mar 24, 2009 12:40 pm
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.