Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • File upload in PHP.

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 235
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: