Interesting File Upload problem...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kafooey

    #1

    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_f ile ( $_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?


  • Martin Wickman

    #2
    Re: Interesting File Upload problem...

    In article <3at4jv8qh84rg7 r5qcbaio1d1ssh8 dt9kn@4ax.com>, kafooey wrote:[color=blue]
    >
    > $upload_result =
    > move_uploaded_f ile ( $_FILES['userfile']['tmp_name'],$dest_filename );
    >
    > $chmod_result = chmod ($dest_filename , 0777);
    >[/color]

    [...]
    [color=blue]
    > 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;[/color]

    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).

    Comment

    • kafooey

      #3
      Re: Interesting File Upload problem...

      On 7 Aug 2003 16:35:52 GMT, Martin Wickman <wizball@hotbre v.com>
      wrote:
      [color=blue]
      >In article <3at4jv8qh84rg7 r5qcbaio1d1ssh8 dt9kn@4ax.com>, kafooey wrote:[color=green]
      >>
      >> $upload_result =
      >> move_uploaded_f ile ( $_FILES['userfile']['tmp_name'],$dest_filename );
      >>
      >> $chmod_result = chmod ($dest_filename , 0777);
      >>[/color]
      >
      >[...]
      >[color=green]
      >> 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;[/color]
      >
      >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).[/color]

      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 :: kafooey@yahoo.c o.uk
      E-Blog :: http://www.pluggedout.com/blog

      Comment

      • matty

        #4
        Re: Interesting File Upload problem...

        kafooey wrote:

        <snippy snip>[color=blue][color=green]
        >>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).[/color]
        >
        > Uploads is inside the webroot.
        >
        > e.g.
        > /pub/home/mywebsitename/htdocs/subfolder/uploads[/color]

        '/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

        Comment

        Working...