我用 PHP 编写了一个脚本来上传图像。
就这一点而言,我的目标是上传并发送 2 张图片到服务器,1 张是原图,1 张是缩略图。我的脚本有效,但并不完美。这是我的脚本
<?php
//this is script for get data type file
$acak = rand(000000,999999);// for random
$lokasi_file = $_FILES['fupload']['tmp_name'];
$nama_file = $_FILES['fupload']['name'];
$nama_file_acak = $acak.$nama_file;
$ukuran_file = $_FILES['fupload']['size'];
$tipe_file = $_FILES['fupload']['type'];
$direktori = "fkendaraan/$nama_file_acak";
$uplod = move_uploaded_file($lokasi_file,"$direktori"); //to move image from local to the server folder
//to handle uplod thumbnail image
$img = imagecreatefromjpeg($direktori);
$width = imagesx($img);
$height = imagesy($img);
$new_width = 200;
$new_height = ($new_width/$width) * $height;
$tmp_img = imagecreatetruecolor( $width, $height );
imagecopyresampled( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
//imagecopyresized( $tmp_img, $img, 200, 200, 0, 0, $new_width, $new_height, $width, $height );
imagejpeg( $tmp_img, $direktori."thumb-".$nama_file_acak );
imagedestroy($tmp_img);
imagedestroy($direktori);
//------------------------------------------------ ---------------
//I have no Problem with query and database, it works fine
$sql = "";
$query = mysql_query($sql);
?>
这可以运行但并不完美,因为这样的结果
任何人都可以帮我解决这个问题吗?我在 php 中非常讨厌