How to Secure Uploader

Started on the old forum in July 2009 · view the original in the archive · old links redirect here

#secured #uploader

15 replies · 1,254 views · started 17 years ago · 1 min read

9 participants
anderson Developer · 146 posts #1

It's long time since I am thinking about to make a secured uploader. I haven't yet add any uploader in my wml lava site due to security issue. But now-a-days many request me for a uploader sothat they can upload their images happily. However, I want to put a secured uploader now.

Now guys I want to have ideas from you all on how can I make my uploader secured. With all the security functions, additionally I want such a uploader that should have the functions like below:

  1. Allows only image(.gif/.jpg/.jpeg/.png/.bmp) MIME type files.
  2. Maximum file size supports 50KB.
  3. "Uploaded file under moderator processing system" sothat site staffs can check the uploaded files before publishing. ================== ================== Now please give me ideas or codes for it.

Wait...

kiLLeR-eyEd_14 Senior · 382 posts #2

anderson wrote: It's long time since I am thinking about to make a secured uploader. I haven't yet add any uploader in my wml lava site due to security issue. But now-a-days many request me for a uploader sothat they can upload their images happily. However, I want to put a secured uploader now.

Now guys I want to have ideas from you all on how can I make my uploader secured. With all the security functions, additionally I want such a uploader that should have the functions like below:

  1. Allows only image(.gif/.jpg/.jpeg/.png/.bmp) MIME type files.
  2. Maximum file size supports 50KB.
  3. "Uploaded file under moderator processing system" sothat site staffs can check the uploaded files before publishing. ================== ================== Now please give me ideas or codes for it.

just limit the extensions of a file to be uploaded

bijaybd Developer · 178 posts #3

just limit the extensions of a file to be uploaded

still my site got hacked by for the uploading system the delete my database so how to secure the hack ????? i got file extention gif and jpeg but how they do that i really dont know

ori Lead · 512 posts #4

u have to make sure the content type is same as the extension

$image_type = array("image/jpeg","image/pjpeg","image/gif","image/x-png","image/bmp");
$ext = strtolower(strrchr($_FILES['filetoupload'][name],'.'));
$file_type = $_FILES['filetoupload']['type'];
if (!in_array($ext,$image_ext) && in_array($file_type,$image_type)) echo "Content type must be image.";

thats just an example from my uploader

ori Lead · 512 posts #5

should also stop ur download folders from loading php files thru url / hotlinking etc

anderson Developer · 146 posts #6

ori wrote: should also stop ur download folders from loading php files thru url / hotlinking etc

Want more tips here to make uploader secured. @ ori n other coders

Wait...

kuklux Newbie · 8 posts #7

hide ur image url dir! Get idea from the E-Cards! just like what i did in mah site!

anderson Developer · 146 posts #8

kuklux wrote: hide ur image url dir! Get idea from the E-Cards! just like what i did in mah site!

good point.

plz tell me more tips @ all

Wait...

killfrenzy Newbie · 4 posts #10

put .htaccess...only file that only upload are include...

blackhowk Senior · 411 posts #11

upload images and in the same time change the name of images.insert the new name of image into database.keep the name into database and the name of folder for upload secret(storage).generate image link for viewers into new folder(deliver folder) and in the same time copy and rename the image from storage into deliver.empty deliver folder periodic with a value cron in kb of deliver folder.this prevent hot linking.if you want to resize images at the same value resize in deliver folder.

kiLLeR-eyEd_14 Senior · 382 posts #12

bijaybd wrote: just limit the extensions of a file to be uploaded

still my site got hacked by for the uploading system the delete my database so how to secure the hack ????? i got file extention gif and jpeg but how they do that i really dont know

use a resizer of image..just search here..use it for holding images..then make some codes, if the image is a remote file then use header("Location: $imageurl")..

bijaybd Developer · 178 posts #13

kiLLeR-eyEd_14 wrote: use a resizer of image..just search here..use it for holding images..then make some codes, if the image is a remote file then use header("Location: $imageurl")..

i use phpthumb but still the same thing happening why i really dont know even the image file renamed autometically like if its baby.gif it goes lyk 1234.gif but still same

ori Lead · 512 posts #14

my uploader directory denies even the allowed file types i use a grab file to download files so folder is hidden plus files cant be accessed even if they guess the folder

friend Developer · 112 posts #15

Put code in upload file that some chatpost req to upload files so regular chatter only can upload file .... Also put denied in htacess for php.jpeg etc

Guest #16

Eish.... The easiest way is use

  $file_info = getimagesize($_FILES['image']['tmp_name']);
  
  if(empty($file_info)) {
        $error_msg = "The uploaded file doesn't seem to be an image.";
      $upload_error = 1;      
  }

Only an image file will return a true value.

Or if you really want to go all out make files only down loadable so that when someone hotlinks to your file he/she will not be able to run the file but not download it. It is a bit tricky but I am willing to help if needed.

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close