468,242 Members | 1,537 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,242 developers. It's quick & easy.

Interesting File Upload problem...

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
3 3317
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
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
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.

Similar topics

2 posts views Thread by matt | last post: by
3 posts views Thread by Bijoy Naick | last post: by
6 posts views Thread by tshad | last post: by
5 posts views Thread by William LaMartin | last post: by
6 posts views Thread by Vic Spainhower | last post: by
7 posts views Thread by pbd22 | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.