btw berhubung aku upload error scriptnya, aku potong beberapa script.
jadi maklum kalau ada error hehehe
$error = false;
$file = false;
include "db.inc.php";
$upload_dir=dirname($_SERVER["SCRIPT_FILENAME"]);
if (!$error && isset($_REQUEST["uploadbutton"]))
$size = $_FILES["dumpfile"]["size"];
if ($size < 500000) {
{ if (is_uploaded_file($_FILES["dumpfile"]["tmp_name"]) && ($_FILES["dumpfile"]["error"])==0)
{
$uploaded_filename=str_replace(" ","_",$_FILES["dumpfile"]["name"]);
$uploaded_filepath=str_replace("//admin/files/","/",$upload_dir."/".$uploaded_filename);
if (file_exists($uploaded_filename))
{ echo ("
File $uploaded_filename already exist! Delete and upload again!
\n"); }else if !@move_uploaded_file($_FILES["dumpfile"]["tmp_name"],$uploaded_filepath))
{ echo ("
Error moving uploaded file ".$_FILES["dumpfile"]["tmp_name"]." to the $uploaded_filepath
\n");echo ("
Check the directory permissions for $upload_dir (must be 777)!
\n");}
else
{ echo ("
Uploaded file saved as $uploaded_filename
\n");$save = $uploaded_filename;
$file = $uploaded_filename;
header('Content-type: image/jpeg') ;
list($width, $height) = getimagesize($file) ;
$modwidth = 100;
$modheight = 100;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
// Here we are saving the .jpg, you can make this gif or png if you want
//the file name is set above, and the quality is set to 100%
imagejpeg($tn, $save, 100) ;
$filepath = "$uploaded_filename";
@unlink($filepath); }
}
else
{ echo ("
Error uploading file ".$_FILES["dumpfile"]["name"]."
\n");}}}
else{echo "file kegedean $size";}
if ($filename==""){
?>
form method="POST" action=" echo '".$PHP_SELF."'; " enctype="multipart/form-data"
input type="hidden" name="MAX_FILE_SIZE" value="$upload_max_filesize"
p align="center">input type="file" name="dumpfile" accept="*/*" size="60"p align="center">input type="submit" name="uploadbutton" value="Upload"
/p>
/form>
No comments:
Post a Comment