Hi,

I'm making a online posting ad web application and it will require the end user to upload a image of his/her item. I'm working on the preview post function as of now and would like to know if the way I'm doing it leaves any major security risks.

Once a user posts his info and attaches his image to be uploaded, it will lead to a preview page that will view this image from a tmp folder (not outside my web directory). If he clicks "Choose a different image" then it will lead to the previous page and at the same time delete that image in the tmp folder. If he clicks submit final, then it will store the posting info and move the image in the tmp folder to the folder all images will be stored in.

For the upload code, I have a limit set and I check the file extension along with the MIME type. I only allow .gif, .jpeg, and .tiff.

Some of the possible security risks that come to mind is if a user decides to keep uploading to the tmp folder and not doing anything after, therefore it will leave that image uploaded inside the tmp folder. Someone may make a script to auto fill the post and upload tons of images inside my directory. To counter this I can probably do a post verification, but don't really want to if not necessary (as in other methods to carry out my function that will not need to do this).

Thanks for taking your time to read this.
tanger

In reply to Preview uploaded image by tanger

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.