Jump to content

Uploading image error


fear126

Recommended Posts

I m using that following code but idk image is getting unable to upload

 

$Destination = 'assets/images/avatar/';

if(!isset($_FILES['ImageFile']) || !is_uploaded_file($_FILES['ImageFile']['tmp_name']))

{

die('Something went wrong with Upload!');

}

 

$RandomNum = rand(0, 9999999999);

 

$ImageName = str_replace(' ','-',strtolower($_FILES['ImageFile']['name']));

$ImageType = $_FILES['ImageFile']['type']; //"image/png", image/jpeg etc.

 

$ImageExt = substr($ImageName, strrpos($ImageName, '.'));

$ImageExt = str_replace('.','',$ImageExt);

 

$ImageName = preg_replace("/\.[^.\s]{3,4}$/", "", $ImageName);

 

//Create new image name (with random number added).

$NewImageName = $ImageName.'-'.$RandomNum.'_'.$membername.'.'.$ImageExt;

 

move_uploaded_file($_FILES['ImageFile']['tmp_name'], "$Destination/$NewImageName");

 

Please help

Link to comment
https://forums.phpfreaks.com/topic/296337-uploading-image-error/
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.