afishare pe interfata din upload/rezise image dupa id tabel

Ai o întrebare legată de PHP? Incercăm să îi găsim soluţie. Sau poate doar vrei să publici un cod interesant.

Moderatori: Zamolxe, Moderatori

Avatar utilizator
maniac0man
PHPRomania Supporter
Mesaje: 13
Membru din: Vin Aug 31, 2007 9:30 pm

afishare pe interfata din upload/rezise image dupa id tabel

Mesajde maniac0man » Vin Aug 31, 2007 9:46 pm

Ash avea nevoie ca imaginea micshorata sa mi se afisheze pe o interfatza php intr`o anumita colona de tabel cum se afiseaza informatziile din baza de date gen !

<td height="22" colspan="3" valign="middle">'.$row['Nume_Produs'].'</td>

'.$row['Nume_Produs'].' --- >>> fiind functia de afishare !

Asta este ceea ce am reuhit eu :

<a href="'.$prod_img.'"><img src="'.$prod_img_thumb.'" width="'.$new_width.'" heigt="'.$new_height.'"
alt="'.$row['nume_produs'].'" style="border:1px #000000"></a>


dar nu merge .... nishte solutzii ??


--->>Acesta este fishierul de up-load al imagini care dupa ce se executa form-ul afisheaza imaginea micshorata !


<?php

if(isset($_POST['Submit']))

{
$size = 100; // the thumbnail height

$filedir = 'pics/'; // the directory for the original image
$thumbdir = 'pics/'; // the directory for the thumbnail image
$prefix = 'small_'; // the prefix to be added to the original name

$maxfile = '2000000';
$mode = '0666';

$userfile_name = $_FILES['image']['name'];
$userfile_tmp = $_FILES['image']['tmp_name'];
$userfile_size = $_FILES['image']['size'];
$userfile_type = $_FILES['image']['type'];

if (isset($_FILES['image']['name']))
{
$prod_img = $filedir.$userfile_name;

$prod_img_thumb = $thumbdir.$prefix.$userfile_name;
move_uploaded_file($userfile_tmp, $prod_img);
chmod ($prod_img, octdec($mode));

$sizes = getimagesize($prod_img);

$aspect_ratio = $sizes[1]/$sizes[0];

if ($sizes[1] <= $size)
{
$new_width = $sizes[0];
$new_height = $sizes[1];
}else{
$new_height = $size;
$new_width = abs($new_height/$aspect_ratio);
}

$destimg=ImageCreateTrueColor($new_width,$new_height) or die('Problem In Creating image');

$srcimg=ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image');

ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');

ImageJPEG($destimg,$prod_img_thumb,90) or die('Problem In saving');

imagedestroy($destimg);
}

echo '
<a href="'.$prod_img.'">
<img src="'.$prod_img_thumb.'" width="'.$new_width.'" heigt="'.$new_height.'">
</a>';

}else{

echo '
<form method="POST" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data">
<input type="file" name="image"><p>
<input type="Submit" name="Submit" value="Submit">
</form>';
}



Cosmin Chiru
Senior Member
Mesaje: 251
Membru din: Joi Apr 19, 2007 3:44 pm

Mesajde Cosmin Chiru » Sâm Sep 01, 2007 2:07 pm

Incearca phpThumb

Avatar utilizator
maniac0man
PHPRomania Supporter
Mesaje: 13
Membru din: Vin Aug 31, 2007 9:30 pm

Mesajde maniac0man » Sâm Sep 01, 2007 3:28 pm

Vreau ca acest cod sa`mi fie foarte clar in modul in care el functioneaza !

Deci :
- Scriptul de upload afisheaza imaginea micshorata in upload.php
- Vreau ca acest script de up-load sa`l integrez pe o interfaza PHP am unui magazin virtual ... deci sa pot afisa poze ptr. diferite id-uri de tabel !


:?: :?: :?: :?: :?:


Înapoi la “Cod PHP”

Cine este conectat

Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 41 vizitatori