Jump to content

[SOLVED] uploading only images


shadiadiph

Recommended Posts

This is just the extensio part of what I have.... If you can't figure out the rest,,, post your code that you have for your upload script. This will only allow .jpg ,,, you can add others.

<?php
$filename = stripslashes($_FILES['image']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg"))
{
  Have your error here.
}

Just so you know,, this is far from secure from what I have heard. How,, I don't know.. Still learning myself

Another option is to use the getimagesize function to validate if the file uploaded is indeed an image...

 

// validation... since this is an image upload script we should run a check 

// to make sure the uploaded file is in fact an image. Here is a simple check:

// getimagesize() returns false if the file tested is not an image.

@getimagesize($_FILES[$fieldname]['tmp_name'])

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.