php execution prevent on folder?

Discussion in 'Apache' started by daninosanto, Jan 12, 2010.

  1. #1
    I have a website that users can upload images to uploads directory. I have prevented user to upload files whose extension is other than jpg,gif and png. But if user uploads a php file that has no extension or extension like filename1.php.jpg the server will accept the file.

    What I am trying to do is make uploads folder not accessible by PHP. php should not try to execute any file under that directory (recursively).

    How can I do that? What modification is needed in httpd.config? Is there a need for modification to http.config file
     
    daninosanto, Jan 12, 2010 IP
  2. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #2
    It'd be better to modify the script controlling the upload to verify that the file is of type jpeg, that way you don't have to worry about all the other possibilities you've not thought of yet.
     
    tolra, Jan 13, 2010 IP
  3. hostechsupport

    hostechsupport Well-Known Member

    Messages:
    413
    Likes Received:
    23
    Best Answers:
    7
    Trophy Points:
    138
    #3
    Hello,

    This can be controlled through scripts only. As there is no specification of uploading a particular range of files for a particular directory in httpd configuration file, as whatever entries we make, the effect is on domain.

    The control that you are talking about has to be controlled through a code only.

    Thank you.
    Regards,
    Hostech Support
     
    hostechsupport, Jan 13, 2010 IP
  4. daninosanto

    daninosanto Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you for your answers.
     
    daninosanto, Jan 14, 2010 IP