Link to home
Start Free TrialLog in
Avatar of bbrunning
bbrunningFlag for United States of America

asked on

php upload script not working

Here's the code I put in my index.php file:
<?php
if(isset($_FILES['upload']))
{
    if(move_uploaded_file($_FILES['upload']['tmp_name'], "/var/www/virtual/globalsourcingintl.com/upload/htdocs/uploads/$_FILES[upload]['name]"))
    echo "File uploaded successfully";
    else echo "Problem uploading file";
}
?>

<form action="" method="post" enctype="multipart/form-data">
<p>Select file to upload<input type="file" name="upload" /></p>
<input type="submit" value="Upload" />
</form>

I cannot get this to work. This is a dedicated server running ubuntu, I have 2 domains and a subdomain. The subdomain is where the upload script is: upload.globalsourcingintl.com. The absolute path to the upload directory is /var/www/virtual/globalsourcingintl.com/upload/htdocs/uploads/
But that's the path when I'm logged in as root under ssh. Everytime I try to upload something I get the else error.
Another thing: I have the subdomains main directory protected using .htaccess and .htpasswd, I am logged in before actually trying to upload the files.

Any Ideas?
ASKER CERTIFIED SOLUTION
Avatar of Ionut A. Tudor
Ionut A. Tudor
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bbrunning

ASKER

I've already done that. no luck
nvm, I guess in the hectic problems I was having I deleted and recreated the directory when I was messing around and accidentally forgot to chmod 777 again. You were right.

Thanks