By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,669 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

Interesting File Upload problem...

P: n/a
Hi all,

I've been digging around on the newsgroups and the web for a possible
answer for this problem, but have so far come up with nothing so
thought I would ask here...

I have the following code doing a file upload...
$upload_result =
move_uploaded_file ( $_FILES['userfile']['tmp_name'],$dest_filename);

$chmod_result = chmod ($dest_filename, 0777);
The destination folder is set to permission 777, and the code above
reports success. Looking through an FTP client or SSH client I can
confirm that the file is there, and it's permission has been set to
777.

However... when I go to a browser and try to look at the file, the
browser reports;

Forbidden
You don't have permission to access /uploads/19.jpg on this server.

This doesn't make sense because I can see manually uploaded files in
that folder. Also (by luck) I also discovered that if I try to chmod
the uploaded file, I get the following error;

550 Could not change perms on [filename] : Bad file descriptor
I thought "aha - perhaps the file is corrupt", so downloaded it back
to my machine via FTP, and it appears to be fine so it's not that.

I also checked the hierarchy of folders (because the uploads folder is
within another folder), and confirmed that all the folders have
permission 777.

Does anybody have any idea whats going on?
Jul 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
In article <3a********************************@4ax.com>, kafooey wrote:

$upload_result =
move_uploaded_file ( $_FILES['userfile']['tmp_name'],$dest_filename);

$chmod_result = chmod ($dest_filename, 0777);

[...]
However... when I go to a browser and try to look at the file, the
browser reports;

Forbidden
You don't have permission to access /uploads/19.jpg on this server.

This doesn't make sense because I can see manually uploaded files in
that folder. Also (by luck) I also discovered that if I try to chmod
the uploaded file, I get the following error;


1. Is '/uploads/' inside the webroot at all?

2. Are you sure there are no restrictions on '/uploads'? That is,
httpd.conf may not allow GET to that directory (which seems reasonable
or you'd have an open warez site on your hands).

Jul 16 '05 #2

P: n/a
On 7 Aug 2003 16:35:52 GMT, Martin Wickman <wi*****@hotbrev.com>
wrote:
In article <3a********************************@4ax.com>, kafooey wrote:

$upload_result =
move_uploaded_file ( $_FILES['userfile']['tmp_name'],$dest_filename);

$chmod_result = chmod ($dest_filename, 0777);


[...]
However... when I go to a browser and try to look at the file, the
browser reports;

Forbidden
You don't have permission to access /uploads/19.jpg on this server.

This doesn't make sense because I can see manually uploaded files in
that folder. Also (by luck) I also discovered that if I try to chmod
the uploaded file, I get the following error;


1. Is '/uploads/' inside the webroot at all?

2. Are you sure there are no restrictions on '/uploads'? That is,
httpd.conf may not allow GET to that directory (which seems reasonable
or you'd have an open warez site on your hands).


Uploads is inside the webroot.

e.g.
/pub/home/mywebsitename/htdocs/subfolder/uploads

I've put a support call in with the host (valuehost) so I'll see what
they come back with.
E-Mail :: ka*****@yahoo.co.uk
E-Blog :: http://www.pluggedout.com/blog
Jul 16 '05 #3

P: n/a
kafooey wrote:

<snippy snip>
1. Is '/uploads/' inside the webroot at all?

2. Are you sure there are no restrictions on '/uploads'? That is,
httpd.conf may not allow GET to that directory (which seems reasonable
or you'd have an open warez site on your hands).


Uploads is inside the webroot.

e.g.
/pub/home/mywebsitename/htdocs/subfolder/uploads


'/uploads' isn't inside the webroot.

'/pub/home/mywebsitename/htdocs/subfolder/uploads' (or whatever)
is.

If you are naming the folder correctly, then check your version of PHP,
since some have an issue with openbasedir and safe_mode
Jul 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.