النتائج 1 إلى 2 من 2

الموضوع: كيف طريقة عمل صورة مصغرة كنسخة من صورة تم تحميلها؟؟!!

  1. #1
    عضو فعال جدا
    تاريخ التسجيل
    Jun 2003
    المشاركات
    2,270

    كيف طريقة عمل صورة مصغرة كنسخة من صورة تم تحميلها؟؟!!



    السلام عليكم

    اخواني عملت كود يقوم بتحميل 10 صور في كل مرة ولاكن الذي اريده ان يقوم الكود بعمل صورة مصغرة thumbnail عند التحميل ويكون عرض الصورة 180 بكسل ويقوم الكود بتخزين الصورة الحقيقية على الفولدر التالي
    كود:
    ../Products/
    واريد الصورة الجديدة المصغرة ان تخزن على المسار التالي
    كود:
    .../Products/Thumbnails

    هذا الكود الحالي lموجود داخل الصفحة التي ينتقل اليها المستخدم بعد ان يتحول من الفورم


    كود:
    $images = "";
    
    while(list($key,$value) = each($_FILES[images][name]))
    {
    if(!empty($value)){   // this will check if any blank field is entered
    
    $filename = $value;    // filename stores the value
    $images .= $filename;
    $images .= ",";
    
    $filename=str_replace(" ","-",$filename); // Add - inplace of blank space in file name, you can remove this line
    
    $add = "../Products/$filename";   // upload directory path is set
    copy($_FILES[images][tmp_name][$key], $add);     //  upload the file to the server
    }
    }
    
    $images = substr($images, 0, -1);


    وهذا الكود موجود داخل الفوم

    كود:
    for($i=1; $i<= 10; $i++){
    echo "Image $i: <input type='file' name='images[]' class='bginput'><br />";
    }


    شكرا جزيلا للمساعدة

    بارك الله فيكم





    __________________


    عاشت فلسطين وعاشت المقاومة
    http://www.palintefada.com/arabic
    http://www.palissue.com/arabic
    موقع انتفاضة فلسطين - موقع القضية الفلسطينية
    الكاسر



  2. #2
    عضو فعال جدا
    تاريخ التسجيل
    Jun 2003
    المشاركات
    2,270


    اخواني الكرام

    حاولت اعمل الكود - مرحلة تحميل الصورة 100% ولاكن لا اعلم لمذا لا يقوم السكربت بعمل صورة مصغرة ورفعها على المسار المخصص

    هذا هو الكود الحالي

    كود:
    
    <?php 
    
    include("../includes/meta.php");
    require_once("../includes/connection.php");
    
    $action = $_GET['add'];
    
    $max_no_img = 10; // Maximum number of images value to be set here
    
    
    
    
    
    function createThumbs( $pathToImages, $pathToThumbs, $fname, $thumbWidth )
    {
      // open the directory
      $dir = opendir( $pathToImages );
    
      $fname = readdir( $dir );
        // parse path for the extension
        $info = pathinfo($pathToImages . $fname);
        // continue only if this is a JPEG image
        if ( strtolower($info['extension']) == 'jpg' )
        {
          //echo "Creating thumbnail for {$fname} <br />";
    
          // load image and get image size
          $img = imagecreatefromjpeg( "{$pathToImages}{$fname}" );
          $width = imagesx( $img );
          $height = imagesy( $img );
    
          // calculate thumbnail size
          $new_width = $thumbWidth;
          $new_height = floor( $height * ( $thumbWidth / $width ) );
    
          // create a new temporary image
          $tmp_img = imagecreatetruecolor( $new_width, $new_height );
    
          // copy and resize old image into new image
          imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
    
          // save thumbnail into a file
          imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" );
        }
      
      // close the directory
      closedir( $dir );
    }
    
    
    
    ?>
    
    <title>add product</title>
    </head>
    <body>
    	<div id="container">
    
    
    <?php
    
    if($action == "ok"){
    
    $title = trim($_POST['ProductName']);
    $number = trim($_POST['ProductNumber']);
    $desc = trim($_POST['ProductDescription']);
    $Price = floatval($_POST['ProductPrice']);
    $WasPrice = floatval($_POST['ProductWasPrice']);
    
    
    if ($title == ""){
    echo "<br /><br /><p style=\"color: red;\">You must enter a Product Name</p><br /><br />";
    } else if ($number == ""){
    echo "<br /><br /><p style=\"color: red;\">You must enter a Product Number</p><br /><br />";
    } else if ($desc == ""){
    echo "<br /><br /><p style=\"color: red;\">You must enter a Product Description</p><br /><br />";
    } else if (empty($Price)){
    echo "<br /><br /><p style=\"color: red;\">You must enter a Product Price</p><br /><br />";
    } else if ($Price >= $WasPrice){
    echo "<br /><br /><p style=\"color: red;\">Product Price must be greater that Product Was Price</p><br /><br />";
    } else {
    
    
    
    
    
    
    
    
    $images = "";
    
    while(list($key,$value) = each($_FILES[images][name]))
    {
    	if(!empty($value)){   // this will check if any blank field is entered
    
    	$filename = $value;    // filename stores the value
    
    	$NewName = $number;
    	$NewName .= substr($filename, 0, strrpos( $filename ,"."));
    
    	$NewName = str_replace(" ","-", $NewName); // Add - inplace of blank space in file name, you can remove this line
    	$NewName .= rand(100, 1000000);
    
    	$NewName .= substr($filename, strrpos( $filename ,".") );
    
    	$images .= $NewName; 
    	$images .= ",";
    
    	$add = "../Products/$NewName";   // upload directory path is set
    	copy($_FILES[images][tmp_name][$key], $add);     //  upload the file to the server
    	sleep(3);
    	createThumbs( "../Products/", "../Products/Thumbs/", $NewName , "180" );
    	}
    
    }
    
    $images = substr($images, 0, -1);
    
    
    
    
    
    
        $sql_add = mysql_query("INSERT INTO Products (Title, Description, Pictures, ItemNum, ProductPrice, ProductWasPrice) VALUES ('$title' , '$desc' , '$images' , '$number' , '$Price' , '$WasPrice') ");
        if($sql_add){
    
        echo "<br /><br /><p style=\"color: green;\">A new product has been added</p><br /><br />";
        } else {
        echo "<br /><br /><p style=\"color: red;\">Error occurred while trying to add new product to the database</p><br /><br />";
        }
    
    
    }
    echo "</div>
    </body>
    </html>";
    
    
    exit();
    }
    
    
    	?>
    
    
    <form method="post" action="Products-Add.php?add=ok" enctype="multipart/form-data">
      <table cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-style: solid; border-width: 1px; border-color: #333333;" width="770"> 
    
       <tr>
           <td style="text-align: left; border: 1px #333333; " width="30%">Product Name:</td>
          <td style="text-align: left; border: 1px #333333; " width="70%"><input type="text" name="ProductName" size="50" /></td>
        </tr>
    
    
        <tr>
        <td style="text-align: left; border: 1px #333333; " width="30%">Product Number:</td>
          <td style="text-align: left; border: 1px #333333; " width="70%"><input type="text" name="ProductNumber" size="7" /></td>
      </tr>
    
    
    
        <tr>
        <td style="text-align: left; border: 1px #333333; " width="30%">Product Price:</td>
          <td style="text-align: left; border: 1px #333333; " width="70%"><input type="text" name="ProductPrice" size="7" /></td>
      </tr>
    
    
    
        <tr>
        <td style="text-align: left; border: 1px #333333; " width="30%">Product Was Price:</td>
          <td style="text-align: left; border: 1px #333333; " width="70%"><input type="text" name="ProductWasPrice" size="7" /></td>
      </tr>
    
    
    
        <tr>
        <td style="text-align: left; border: 1px #333333; " width="30%">Product Description:</td>
          <td style="text-align: left; border: 1px #333333; " width="70%"><textarea name="ProductDescription" cols="60" rows="10"></textarea></td>
      </tr>
    
    
        <tr>
        <td style="text-align: left; border: 1px #333333; " width="30%">Product Pictures:</td>
          <td style="text-align: left; border: 1px #333333; vertical-align: top;" width="70%">
    
    
    
    <?php
    echo "<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse; border-style: dotted; border-width: 1px; border-color: #333333;\" width=\"95%\"> 
    <tr><td>Num</td><td>Main Pic</td><td>Select an Image<td></tr>";
    for($i=1; $i<= $max_no_img; $i++){
    
    		if ($i == 1) { 
    		$SELECTED = " checked "; 
    		} else { 
    		$SELECTED = ""; 
    		}
    
    echo "<tr><td style=\"border: 1px dotted #333333;\">Image $i</td><td style=\"border: 1px dotted #333333;\"><input type=\"radio\" name=\"MainPic[]\" $SELECTED /></td><td style=\"border: 1px dotted #333333;\"> <input type='file' name='images[]' class='bginput' /></td></tr>";
    }
    
    echo "</table>";
    ?>
    
    
    
    
    </td>
      </tr>
    
    
     </table>
    
    <br />
    <input type="submit" value="Add Product" /> 
    
    </form>
    
    
    
    
    
    	
    	</div>
    </body>
    </html>






    __________________


    عاشت فلسطين وعاشت المقاومة
    http://www.palintefada.com/arabic
    http://www.palissue.com/arabic
    موقع انتفاضة فلسطين - موقع القضية الفلسطينية
    الكاسر






ضوابط المشاركة

  • لا تستطيع إضافة مواضيع جديدة
  • لا تستطيع الرد على المواضيع
  • لا تستطيع إرفاق ملفات
  • لا تستطيع تعديل مشاركاتك
  •  

أضف موقعك هنا| اخبار السيارات | حراج | شقق للايجار في الكويت | بيوت للبيع في الكويت | دليل الكويت العقاري | مقروء | شركة كشف تسربات المياه | شركة عزل اسطح بالرياض | عزل فوم بالرياض| عزل اسطح بالرياض | كشف تسربات المياة بالرياض | شركة عزل اسطح بالرياض