0
我已經使用PHP編寫了一個腳本來上傳圖像。使用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);
?>
這可以運行,但並不完美,因爲結果是這樣
任何人都可以幫助我解決這個問題嗎?林非常nubie在PHP
謝謝你,它的工作.... – Uchsun