Jump to content

Image Upload Script


onlyican

Recommended Posts

Hi All

Not so much help as here is a handy class for uploading images

Please feel free to find security bugs and let me know.

Also feel free to use it if you want.

 

http://onlyican.com/test_samples/bl_upload_img.phps

 

To use the class, simply use the following

require_once('bl_upload_img.php');
$objUploadImg = new UploadImg();
//Set values here if you wish such as 
$objUploadImg->setFormField('myFormField'); // The Name from <input type="file" name="myFormField" />
$objUploadImg->setSaveDirMain($_SERVER['DOCUMENT_ROOT'].'/MyImageFolder'; //Make sure to set the permissions

//You can change most settings, just look at the function setDetaultValues() to get the function name
//Now upload the image
if($objUploadImg->uploadImage()){
			  $strFileName = $objUploadImg->getFileNameMain();

		  }else{
			  echo 'Error uploading Image<br />'.$objUploadImg->getErrorMessage();

		  }

Link to comment
https://forums.phpfreaks.com/topic/209967-image-upload-script/
Share on other sites

Could do,

 

Was also going to add better error handling

So system Errors dont echo out the same as User errors.

 

(IE, currently, Folder not valid and file not an image is handled together)

Then put errors in an array, so the user can either get the error ID and make there own message or can update the Error Handling Array.

 

Link to comment
https://forums.phpfreaks.com/topic/209967-image-upload-script/#findComment-1095954
Share on other sites

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.