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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.