We help IT Professionals succeed at work.
Get Started

php upload script not working

bbrunning asked
Last Modified: 2012-05-06
Here's the code I put in my index.php file:
    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" />

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?
Watch Question
PHP Programmer
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE