Hello Reader's ,
While building any appication we definatley requires images to upload like profile image , company image etc , for this we require php file upload code .
You will get image data in array i.e. image name , temp name , image size , image type.
$image_name = $image['name'];
$image_temp_name = $image['tmp_name'];
IMAGE_URL = Path to your upload folder.
if(!empty($image_name)){
$priv1 = 0777;
$imgpath= IMAGE_URL."/uploads";
if(!file_exists($imgpath)){
mkdir($imgpath, $priv1) ? true : false; // creates a new directory with write permission.
}
$imagename=time().'_'.$image['name']; // make unique image name using time function
$filename=$imgpath."/".$imagename;
move_uploaded_file($image_temp_name,$filename);
$file_path=$imagename;
}
0 Comment(s)