Upload not finding directory to write to.
| From: | Dave M G | Date: | Sat, 28 Oct 2006 05:49:17 +0000 |
| Subject: | Upload not finding directory to write to. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-243784@lists.php.net to get a copy of this message | ||
PHP List,
I had a file upload script which was working fine. Then, because of other needs, I changed my local Apache settings so that my local web site directory structure behaved the same as they do on my web hosting service.
What I mean by that is that before, I would access my local web sites by going to their directories within the localhost (/var/www) directory:
localhost/web_sites/web_site_one/index.php
Now I just go to:
web_site_one/
If i create a link that says <a href="/">link</a>, it goes to the root of the web site, where the index.php is.
Within that root directory, I have a directory called "image", where I'm trying to put my uploaded image files.
The destination file location should then be "/image/", shouldn't it?
My code looks like this:
$fileLocation = "/image/" . $_POST['name'];
if(move_uploaded_file($_FILES['file']['tmp_name'], $fileLocation))
{
chmod ($fileLocation, 0777);
}
$_POST['name'] is a name for the file that the user has entered.
But this now gives me an error that it can't open a stream to the destination.
I also checked to make sure that the "image" directory has fully open permissions, and it's currently set to "drwxrwxrwx", or "0777".
Am I missing some fundamental issue with directory structures on an Apache server?
--
Dave M G
Ubuntu 6.06 LTS
Kernel 2.6.17.7
Pentium D Dual Core Processor
PHP 5, MySQL 5, Apache 2