I have code:
//Get image from form
$image = $_FILES['image']['tmp_name'];
//Convert to base64
$imageData = base64_encode(file_get_contents($image));
//Set mime type
header('Content-Type: image/gif');
//Decode to image
$image = base64_decode($imageData);
//Save in server
$res = file_put_contents(ROOT_DIR . "/uploads/fotos/" . $row['user_id'] . ".gif", $image);
The problem is that it is at this point header ('Content-Type: image / gif'); displays the image in the browser. How do I change the mime type does not output the result to the browser. The ultimate goal of saving all the images on a server in the format and type of gif.
If you are just uploading the image onto the server then you need not to use
header('Content-Type: image/gif');// remove this
it is used to output the image file to the browser. if everything is ok then to upload file use php file upload function
move_uploaded_file ( string $filename , string $destination )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.