Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php image rotate upload

    //START Update the user image
if(isset($_POST['user_image_id'])){

    $upload_image_id = $_POST['user_image_id'];
    $user_image = $_FILES['user_image']['name'];
    $filePath = $_FILES['user_image']['tmp_name'];

   $image = imagecreatefromstring(file_get_contents($_FILES['user_image']['tmp_name']));
    $exif = exif_read_data($filePath);
    if(!empty($exif['Orientation'])) {
        switch($exif['Orientation']) {
           case 8:
               $image = imagerotate($image,90,0);
               break;
           case 3:
               $image = imagerotate($image,180,0);
               break;
           case 6:
               $image = imagerotate($image,-90,0);
               break;
       }
   }
    // $image now contains a resource with the image oriented correctly

    //create image target to upload
    $image_target = $folder_target.basename($_FILES['user_image']['name']);

    //upload the image the and update the name of the image
    if(move_uploaded_file($_FILES['user_image']['tmp_name'], $image_target)){
        if ($conn->query("UPDATE `users` SET `image`='$user_image' WHERE `id` LIKE '$upload_image_id'")){
            echo 1;
        }else{
            echo "not update the name, Proplem";
        }
    }else{
        echo 'image not uploaded';
    }

}
Comment

PREVIOUS NEXT
Code Example
Php :: wordpress rename post format 
Php :: get users other than specific role laravel role spatie 
Php :: fgets in php 
Php :: Cambiar la imagen por defecto en producto WooCommerce 
Php :: dependable validation in laravel 
Php :: get admin url wordpress 
Php :: logout from all the devices in the jwt api laravel 
Php :: laravel imap - Get message attachments 
Php :: laravel 6 make http request 
Php :: googlee traduction 
Php :: transaction laravel 
Php :: php script read source code web 
Php :: Remove .php extension & Remove trailing slash 
Php :: laravel logout all users 
Php :: round to 0.5 php 
Php :: json_encode() 
Php :: php get first element of iterator class 
Php :: laravel copy 
Php :: wp plugin create 
Php :: php require_once 
Php :: how to run curl command through php script 
Php :: display data from two dimensional array in vew laravel 
Php :: laravel get biggest id 
Php :: PHP strrpos — Find the position of the last occurrence of a substring in a string 
Php :: laravel custom pagination 
Php :: firstOrFail() 
Php :: laravel error messages 
Php :: lastinsertId php 
Php :: php sort by key 
Php :: laravel textarea value 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =