prototype Posted April 3, 2014 Share Posted April 3, 2014 Merhaba arkadaşlar elimde basit bir resim upload scripti var otomatik resim boyutlandırma falan yapıyor ancak resimlere benzersiz isim atmıyor. Buda sunucudaki aynı isimdeki resmi silip üstüne yeni resmi atıyor ve sıkıntı oluyor. Aşağıda vermiş olduğum kodda resimlere nasıl benzersiz isim atayabiliriz yardımcı olursanız sevinirim..[spoiler]<?php ini_set("memory_limit", "200000000"); // for large images so that we do not get "Allowed memory exhausted"?> <?php // upload the file if ((isset($_POST["submitted_form"])) && ($_POST["submitted_form"] == "image_upload_form")) { // file needs to be jpg,gif,bmp,x-png and 4 MB max if (($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg" || $_FILES["image_upload_box"]["type"] == "image/gif" || $_FILES["image_upload_box"]["type"] == "image/png") && ($_FILES["image_upload_box"]["size"] < 4000000)) { // some settings $max_upload_width = 2592; $max_upload_height = 1944; // if user chosed properly then scale down the image according to user preferances if(isset($_REQUEST['max_width_box']) and $_REQUEST['max_width_box']!='' and $_REQUEST['max_width_box']<=$max_upload_width){ $max_upload_width = $_REQUEST['max_width_box']; } if(isset($_REQUEST['max_height_box']) and $_REQUEST['max_height_box']!='' and $_REQUEST['max_height_box']<=$max_upload_height){ $max_upload_height = $_REQUEST['max_height_box']; } // if uploaded image was JPG/JPEG if($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg"){ $image_source = imagecreatefromjpeg($_FILES["image_upload_box"]["tmp_name"]); } // if uploaded image was GIF if($_FILES["image_upload_box"]["type"] == "image/gif"){ $image_source = imagecreatefromgif($_FILES["image_upload_box"]["tmp_name"]); } // BMP doesn't seem to be supported so remove it form above image type test (reject bmps) // if uploaded image was BMP if($_FILES["image_upload_box"]["type"] == "image/bmp"){ $image_source = imagecreatefromwbmp($_FILES["image_upload_box"]["tmp_name"]); } // if uploaded image was PNG if($_FILES["image_upload_box"]["type"] == "image/png"){ $image_source = imagecreatefrompng($_FILES["image_upload_box"]["tmp_name"]); } $remote_file = "img/post/".$_FILES["image_upload_box"]["name"]; imagejpeg($image_source,$remote_file,100); chmod($remote_file,0644); // get width and height of original image list($image_width, $image_height) = getimagesize($remote_file); if($image_width>$max_upload_width || $image_height >$max_upload_height){ $proportions = $image_width/$image_height; if($image_width>$image_height){ $new_width = $max_upload_width; $new_height = round($max_upload_width/$proportions); } else{ $new_height = $max_upload_height; $new_width = round($max_upload_height*$proportions); } $new_image = imagecreatetruecolor($new_width , $new_height); $image_source = imagecreatefromjpeg($remote_file); imagecopyresampled($new_image, $image_source, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height); imagejpeg($new_image,$remote_file,100); imagedestroy($new_image); } imagedestroy($image_source); header("Location: img_upload.php?upload_message=image uploaded&upload_message_type=success&show_image=".$_FILES["image_upload_box"]["name"]); exit; } else{ header("Location: img_upload.php?upload_message=make sure the file is jpg, gif or png and that is smaller than 4MB&upload_message_type=error"); exit; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Hızlı Resim Yükle</title> <style type="text/css"> <!-- body,td,th { font-family: Arial, Helvetica, sans-serif; color: #333333; font-size: 12px; background-color: #FFF; } .upload_message_success { padding:4px; background-color:#009900; border:1px solid #006600; color:#FFFFFF; margin-top:10px; margin-bottom:10px; } .upload_message_error { padding:4px; background-color:#CE0000; border:1px solid #990000; color:#FFFFFF; margin-top:10px; margin-bottom:10px; } .hide_input { visibility: hidden; } .upload_buton { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 18px; color: #FFF; background-color: #62C5C5; height: 30px; width: 150px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; } .upload_buton:hover { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 18px; color: #FFF; background-color: #F03; height: 30px; width: 150px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; } .reg_input { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 14px; color: #666; height: 25px; width: 250px; border: 1px solid #62C5C5; } .reg_input_two { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 14px; color: #666; height: 25px; width: 400px; border: 1px solid #62C5C5; } --> </style> </head> <body> <form action="img_upload.php" method="post" enctype="multipart/form-data" name="image_upload_form" id="image_upload_form" style="margin-bottom:0px;"> <label></label> <input name="image_upload_box" type="file" class="reg_input" id="image_upload_box" size="40" /> <input name="submit" type="submit" class="upload_buton" value="Resmi Yükle" /> <label></label> <input name="max_width_box" type="text" class="hide_input" id="max_width_box" value="420" size="4"> <input name="max_height_box" type="text" class="hide_input" id="max_height_box" value="" size="4"> <br /> <input name="submitted_form" type="hidden" id="submitted_form" value="image_upload_form" /> <noscript></noscript> </form> <br /> Resim yüklendi !. Aşağıdaki link ile resmi paylaşabilirsiniz ! <?php if(isset($_REQUEST['show_image']) and $_REQUEST['show_image']!=''){?> <p> <label> <input name="up_img_show" type="text" class="reg_input_two" id="up_img_show" value="/img/post/<?php echo $_REQUEST['show_image'];?>" /> </label> </p> <?php }?> </body> </html> [/spoiler] Quote Link to comment Share on other sites More sharing options...
KintaRo Posted April 3, 2014 Share Posted April 3, 2014 imagecreate() fonsksiyonu yerine move_uploaded_file() kullanarak yapınca oldu. diğer türlü izin vermiyordu ismi değiştirmeye. eklediğim, sildiğim, değiştirdiğim satırlara not düştüm. [spoiler] <?php ini_set("memory_limit", "200000000"); // for large images so that we do not get "Allowed memory exhausted"?> <?php // upload the file if ((isset($_POST["submitted_form"])) && ($_POST["submitted_form"] == "image_upload_form")) { // file needs to be jpg,gif,bmp,x-png and 4 MB max if (($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg" || $_FILES["image_upload_box"]["type"] == "image/gif" || $_FILES["image_upload_box"]["type"] == "image/png") && ($_FILES["image_upload_box"]["size"] < 4000000)) { // some settings $max_upload_width = 2592; $max_upload_height = 1944; // if user chosed properly then scale down the image according to user preferances if(isset($_REQUEST['max_width_box']) and $_REQUEST['max_width_box']!='' and $_REQUEST['max_width_box']<=$max_upload_width){ $max_upload_width = $_REQUEST['max_width_box']; } if(isset($_REQUEST['max_height_box']) and $_REQUEST['max_height_box']!='' and $_REQUEST['max_height_box']<=$max_upload_height){ $max_upload_height = $_REQUEST['max_height_box']; } /* SİLİNEN SATIRLAR // if uploaded image was JPG/JPEG if($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg"){ $image_source = imagecreatefromjpeg($_FILES["image_upload_box"]["tmp_name"]); } // if uploaded image was GIF if($_FILES["image_upload_box"]["type"] == "image/gif"){ $image_source = imagecreatefromgif($_FILES["image_upload_box"]["tmp_name"]); } // BMP doesn't seem to be supported so remove it form above image type test (reject bmps) // if uploaded image was BMP if($_FILES["image_upload_box"]["type"] == "image/bmp"){ $image_source = imagecreatefromwbmp($_FILES["image_upload_box"]["tmp_name"]); } // if uploaded image was PNG if($_FILES["image_upload_box"]["type"] == "image/png"){ $image_source = imagecreatefrompng($_FILES["image_upload_box"]["tmp_name"]); } */ // ######## EKLENEN SATIRLAR ################ $yeni_isim = time() . "_" . $_FILES["image_upload_box"]['name']; if (move_uploaded_file($_FILES["image_upload_box"]["tmp_name"], "img/post/$yeni_isim.png")) { echo "yuklendi"; } else { echo "yuklenmedi"; } // ################################## $remote_file = "img/post/$yeni_isim.png"; // DEĞİŞEN SATIR imagejpeg($image_source,$remote_file,100); chmod($remote_file,0644); // get width and height of original image list($image_width, $image_height) = getimagesize($remote_file); if($image_width>$max_upload_width || $image_height >$max_upload_height){ $proportions = $image_width/$image_height; if($image_width>$image_height){ $new_width = $max_upload_width; $new_height = round($max_upload_width/$proportions); } else{ $new_height = $max_upload_height; $new_width = round($max_upload_height*$proportions); } $new_image = imagecreatetruecolor($new_width , $new_height); $image_source = imagecreatefromjpeg($remote_file); imagecopyresampled($new_image, $image_source, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height); imagejpeg($new_image,$remote_file,100); imagedestroy($new_image); } imagedestroy($image_source); header("Location: img_upload.php?upload_message=image uploaded&upload_message_type=success&show_image=". $yeni_isim); // DEĞİŞEN SATIR exit; } else{ header("Location: img_upload.php?upload_message=make sure the file is jpg, gif or png and that is smaller than 4MB&upload_message_type=error"); exit; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Hızlı Resim Yükle</title> <style type="text/css"> <!-- body,td,th { font-family: Arial, Helvetica, sans-serif; color: #333333; font-size: 12px; background-color: #FFF; } .upload_message_success { padding:4px; background-color:#009900; border:1px solid #006600; color:#FFFFFF; margin-top:10px; margin-bottom:10px; } .upload_message_error { padding:4px; background-color:#CE0000; border:1px solid #990000; color:#FFFFFF; margin-top:10px; margin-bottom:10px; } .hide_input { visibility: hidden; } .upload_buton { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 18px; color: #FFF; background-color: #62C5C5; height: 30px; width: 150px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; } .upload_buton:hover { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 18px; color: #FFF; background-color: #F03; height: 30px; width: 150px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; } .reg_input { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 14px; color: #666; height: 25px; width: 250px; border: 1px solid #62C5C5; } .reg_input_two { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 14px; color: #666; height: 25px; width: 400px; border: 1px solid #62C5C5; } --> </style> </head> <body> <form action="img_upload.php" method="post" enctype="multipart/form-data" name="image_upload_form" id="image_upload_form" style="margin-bottom:0px;"> <label></label> <input name="image_upload_box" type="file" class="reg_input" id="image_upload_box" size="40" /> <input name="submit" type="submit" class="upload_buton" value="Resmi Yükle" /> <label></label> <input name="max_width_box" type="text" class="hide_input" id="max_width_box" value="420" size="4"> <input name="max_height_box" type="text" class="hide_input" id="max_height_box" value="" size="4"> <br /> <input name="submitted_form" type="hidden" id="submitted_form" value="image_upload_form" /> <noscript></noscript> </form> <br /> Resim yüklendi !. Aşağıdaki link ile resmi paylaşabilirsiniz ! <?php if(isset($_REQUEST['show_image']) and $_REQUEST['show_image']!=''){?> <p> <label> <input name="up_img_show" type="text" class="reg_input_two" id="up_img_show" value="/img/post/<?php echo $_REQUEST['show_image'];?>" /> </label> </p> <?php }?> </body> </html> [/spoiler] Quote Link to comment Share on other sites More sharing options...
prototype Posted April 3, 2014 Author Share Posted April 3, 2014 (edited) KintaRo üstadım Allah senden razı olsun. Sayende oldu çok teşekkür ederim. Şuan sorunsuz çalışıyor..Not: Resimleri resimadi.png.jpg olarak upload ediyordu. Kodlar arasında olan $yeni_isim.png yazan yerleri $yeni_isim olarak değiştirince düzeldi.. Edited April 3, 2014 by prototype Quote Link to comment Share on other sites More sharing options...
Hongis_3 Posted April 3, 2014 Share Posted April 3, 2014 (edited) birazcık eklemeyle kodunuzun yeni hali açıklamalar eklenmiştir [spoiler] <?php ini_set("memory_limit", "200000000"); // for large images so that we do not get "Allowed memory exhausted"?> <?php // upload the file if ((isset($_POST["submitted_form"])) && ($_POST["submitted_form"] == "image_upload_form")) { // file needs to be jpg,gif,bmp,x-png and 4 MB max if (($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg" || $_FILES["image_upload_box"]["type"] == "image/gif" || $_FILES["image_upload_box"]["type"] == "image/png") && ($_FILES["image_upload_box"]["size"] < 4000000)) { // some settings $max_upload_width = 2592; $max_upload_height = 1944; // if user chosed properly then scale down the image according to user preferances if(isset($_REQUEST['max_width_box']) and $_REQUEST['max_width_box']!='' and $_REQUEST['max_width_box']<=$max_upload_width){ $max_upload_width = $_REQUEST['max_width_box']; } if(isset($_REQUEST['max_height_box']) and $_REQUEST['max_height_box']!='' and $_REQUEST['max_height_box']<=$max_upload_height){ $max_upload_height = $_REQUEST['max_height_box']; } // if uploaded image was JPG/JPEG if($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg"){ $image_source = imagecreatefromjpeg($_FILES["image_upload_box"]["tmp_name"]); } // if uploaded image was GIF if($_FILES["image_upload_box"]["type"] == "image/gif"){ $image_source = imagecreatefromgif($_FILES["image_upload_box"]["tmp_name"]); } // BMP doesn't seem to be supported so remove it form above image type test (reject bmps) // if uploaded image was BMP if($_FILES["image_upload_box"]["type"] == "image/bmp"){ $image_source = imagecreatefromwbmp($_FILES["image_upload_box"]["tmp_name"]); } // if uploaded image was PNG if($_FILES["image_upload_box"]["type"] == "image/png"){ $image_source = imagecreatefrompng($_FILES["image_upload_box"]["tmp_name"]); } ///////////// burası yeniden düzenlendi ///////////////////////// // dosya için yeni isim üretilmesi $benzersiz_isim= md5(uniqid(rand())); // dosyanın uzantısının alınması $dosya_uzantisi=end(explode(".",$_FILES["image_upload_box"]["name"])); // yeni dosya adı ve uzantısının birleştirilmesi $yeni_isim=$benzersiz_isim.".".$dosya_uzantisi; $remote_file = "img/post/".$yeni_isim; imagejpeg($image_source,$remote_file,100); chmod($remote_file,0644); ///////////// burası yeniden düzenlendi ///////////////////////// // get width and height of original image list($image_width, $image_height) = getimagesize($remote_file); if($image_width>$max_upload_width || $image_height >$max_upload_height){ $proportions = $image_width/$image_height; if($image_width>$image_height){ $new_width = $max_upload_width; $new_height = round($max_upload_width/$proportions); } else{ $new_height = $max_upload_height; $new_width = round($max_upload_height*$proportions); } $new_image = imagecreatetruecolor($new_width , $new_height); $image_source = imagecreatefromjpeg($remote_file); imagecopyresampled($new_image, $image_source, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height); imagejpeg($new_image,$remote_file,100); imagedestroy($new_image); } imagedestroy($image_source); header("Location: img_upload.php?upload_message=image uploaded&upload_message_type=success&show_image=".$_FILES["image_upload_box"]["name"]); exit; } else{ header("Location: img_upload.php?upload_message=make sure the file is jpg, gif or png and that is smaller than 4MB&upload_message_type=error"); exit; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Hızlı Resim Yükle</title> <style type="text/css"> <!-- body,td,th { font-family: Arial, Helvetica, sans-serif; color: #333333; font-size: 12px; background-color: #FFF; } .upload_message_success { padding:4px; background-color:#009900; border:1px solid #006600; color:#FFFFFF; margin-top:10px; margin-bottom:10px; } .upload_message_error { padding:4px; background-color:#CE0000; border:1px solid #990000; color:#FFFFFF; margin-top:10px; margin-bottom:10px; } .hide_input { visibility: hidden; } .upload_buton { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 18px; color: #FFF; background-color: #62C5C5; height: 30px; width: 150px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; } .upload_buton:hover { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 18px; color: #FFF; background-color: #F03; height: 30px; width: 150px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; } .reg_input { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 14px; color: #666; height: 25px; width: 250px; border: 1px solid #62C5C5; } .reg_input_two { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 14px; color: #666; height: 25px; width: 400px; border: 1px solid #62C5C5; } --> </style> </head> <body> <form action="img_upload.php" method="post" enctype="multipart/form-data" name="image_upload_form" id="image_upload_form" style="margin-bottom:0px;"> <label></label> <input name="image_upload_box" type="file" class="reg_input" id="image_upload_box" size="40" /> <input name="submit" type="submit" class="upload_buton" value="Resmi Yükle" /> <label></label> <input name="max_width_box" type="text" class="hide_input" id="max_width_box" value="420" size="4"> <input name="max_height_box" type="text" class="hide_input" id="max_height_box" value="" size="4"> <br /> <input name="submitted_form" type="hidden" id="submitted_form" value="image_upload_form" /> <noscript></noscript> </form> <br /> Resim yüklendi !. Aşağıdaki link ile resmi paylaşabilirsiniz ! <?php if(isset($_REQUEST['show_image']) and $_REQUEST['show_image']!=''){?> <p> <label> <input name="up_img_show" type="text" class="reg_input_two" id="up_img_show" value="/img/post/<?php echo $_REQUEST['show_image'];?>" /> </label> </p> <?php }?> </body> </html> [/spoiler] Edited April 3, 2014 by Hongis_3 Quote Link to comment Share on other sites More sharing options...
KintaRo Posted April 3, 2014 Share Posted April 3, 2014 Hongis'in uyguladığı çözüm daha iyi, ben yanlış anlamışım olayı. Quote Link to comment Share on other sites More sharing options...
prototype Posted April 3, 2014 Author Share Posted April 3, 2014 Hongis_3 hocam sizin verdiğiniz koduda denedim ancak şöyle bişi oldu upload işlemi bittikten sonra inputa yansıtılan resim adı: 285221_10200235648007912_1806237084_n.jpg şeklinde ama sunucuya atılan dosya adı: 1c76da9dfa999dd9c72c8736d52c432b.jpg şeklinde. Bu yüzden inputa gelen linki alınca resmi açmıyor. Quote Link to comment Share on other sites More sharing options...
Hongis_3 Posted April 3, 2014 Share Posted April 3, 2014 mesajı şimdi gördüm evet haklısınız. düzelttim problemi bu yeni hali. [spoiler] <?php ini_set("memory_limit", "200000000"); // for large images so that we do not get "Allowed memory exhausted"?> <?php // upload the file if ((isset($_POST["submitted_form"])) && ($_POST["submitted_form"] == "image_upload_form")) { // file needs to be jpg,gif,bmp,x-png and 4 MB max if (($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg" || $_FILES["image_upload_box"]["type"] == "image/gif" || $_FILES["image_upload_box"]["type"] == "image/png") && ($_FILES["image_upload_box"]["size"] < 4000000)) { // some settings $max_upload_width = 2592; $max_upload_height = 1944; // if user chosed properly then scale down the image according to user preferances if(isset($_REQUEST['max_width_box']) and $_REQUEST['max_width_box']!='' and $_REQUEST['max_width_box']<=$max_upload_width){ $max_upload_width = $_REQUEST['max_width_box']; } if(isset($_REQUEST['max_height_box']) and $_REQUEST['max_height_box']!='' and $_REQUEST['max_height_box']<=$max_upload_height){ $max_upload_height = $_REQUEST['max_height_box']; } // if uploaded image was JPG/JPEG if($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg"){ $image_source = imagecreatefromjpeg($_FILES["image_upload_box"]["tmp_name"]); } // if uploaded image was GIF if($_FILES["image_upload_box"]["type"] == "image/gif"){ $image_source = imagecreatefromgif($_FILES["image_upload_box"]["tmp_name"]); } // BMP doesn't seem to be supported so remove it form above image type test (reject bmps) // if uploaded image was BMP if($_FILES["image_upload_box"]["type"] == "image/bmp"){ $image_source = imagecreatefromwbmp($_FILES["image_upload_box"]["tmp_name"]); } // if uploaded image was PNG if($_FILES["image_upload_box"]["type"] == "image/png"){ $image_source = imagecreatefrompng($_FILES["image_upload_box"]["tmp_name"]); } ///////////// burası yeniden düzenlendi ///////////////////////// // dosya için yeni isim üretilmesi $benzersiz_isim= md5(uniqid(rand())); // dosyanın uzantısının alınması $dosya_uzantisi=end(explode(".",$_FILES["image_upload_box"]["name"])); // yeni dosya adı ve uzantısının birleştirilmesi $yeni_isim=$benzersiz_isim.".".$dosya_uzantisi; $remote_file = "img/post/".$yeni_isim; imagejpeg($image_source,$remote_file,100); chmod($remote_file,0644); ///////////// burası yeniden düzenlendi ///////////////////////// // get width and height of original image list($image_width, $image_height) = getimagesize($remote_file); if($image_width>$max_upload_width || $image_height >$max_upload_height){ $proportions = $image_width/$image_height; if($image_width>$image_height){ $new_width = $max_upload_width; $new_height = round($max_upload_width/$proportions); } else{ $new_height = $max_upload_height; $new_width = round($max_upload_height*$proportions); } $new_image = imagecreatetruecolor($new_width , $new_height); $image_source = imagecreatefromjpeg($remote_file); imagecopyresampled($new_image, $image_source, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height); imagejpeg($new_image,$remote_file,100); imagedestroy($new_image); } imagedestroy($image_source); header("Location: img_upload.php?upload_message=image uploaded&upload_message_type=success&show_image=".$yeni_isim); exit; } else{ header("Location: img_upload.php?upload_message=make sure the file is jpg, gif or png and that is smaller than 4MB&upload_message_type=error"); exit; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Hızlı Resim Yükle</title> <style type="text/css"> <!-- body,td,th { font-family: Arial, Helvetica, sans-serif; color: #333333; font-size: 12px; background-color: #FFF; } .upload_message_success { padding:4px; background-color:#009900; border:1px solid #006600; color:#FFFFFF; margin-top:10px; margin-bottom:10px; } .upload_message_error { padding:4px; background-color:#CE0000; border:1px solid #990000; color:#FFFFFF; margin-top:10px; margin-bottom:10px; } .hide_input { visibility: hidden; } .upload_buton { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 18px; color: #FFF; background-color: #62C5C5; height: 30px; width: 150px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; } .upload_buton:hover { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 18px; color: #FFF; background-color: #F03; height: 30px; width: 150px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; } .reg_input { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 14px; color: #666; height: 25px; width: 250px; border: 1px solid #62C5C5; } .reg_input_two { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 14px; color: #666; height: 25px; width: 400px; border: 1px solid #62C5C5; } --> </style> </head> <body> <form action="img_upload.php" method="post" enctype="multipart/form-data" name="image_upload_form" id="image_upload_form" style="margin-bottom:0px;"> <label></label> <input name="image_upload_box" type="file" class="reg_input" id="image_upload_box" size="40" /> <input name="submit" type="submit" class="upload_buton" value="Resmi Yükle" /> <label></label> <input name="max_width_box" type="text" class="hide_input" id="max_width_box" value="420" size="4"> <input name="max_height_box" type="text" class="hide_input" id="max_height_box" value="" size="4"> <br /> <input name="submitted_form" type="hidden" id="submitted_form" value="image_upload_form" /> <noscript></noscript> </form> <br /> Resim yüklendi !. Aşağıdaki link ile resmi paylaşabilirsiniz ! <?php if(isset($_REQUEST['show_image']) and $_REQUEST['show_image']!=''){?> <p> <label> <input name="up_img_show" type="text" class="reg_input_two" id="up_img_show" value="/img/post/<?php echo $_REQUEST['show_image'];?>" /> </label> </p> <?php }?> </body> </html> [/spoiler] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.