|
Forum Flash, Actionscript, PHP e MySQL
|
|
|
|
|
|
| Autore |
Messaggio |
suns
esperto

Età: -1988
Registrato: 20/07/05 23:53
Messaggi: 537
|
Oggetto: effettuare funzione dopo upload dati
Inviato: 19.10.09 | 18:00 |
|
|
rieccomi qui impelegato con il php.
mettiamo che faccio un upload di foto in questo determinato modo
| Codice: | <?php
//path to storage
$storage = $_REQUEST["folder"];
//path name of file for storage
$uploadfile = "$storage/" . basename( $_FILES['Filedata']['name'] );
//if the file is moved successfully
if ( move_uploaded_file( $_FILES['Filedata']['tmp_name'] , $uploadfile ) )
{
$answer="ok";
echo "answer=".$answer;
//file failed to move
}else{
$answer="no";
echo "answer=".$answer;
}
?> |
mi serve che una volta effettuato l'upload mi faccia una funzione.
in pratica una volta effettuato l'upload mi prenda la foto che ha uploadato e mi crei la thumb (per il crop e resize ho già lo script, ma come gi dico una volta finito l'upload prendi la foto? ____________________________________________________________ .... |
|
| Torna in cima |
|
|
Sponsor
|
|
 |
suns
esperto

Età: -1988
Registrato: 20/07/05 23:53
Messaggi: 537
|
Oggetto:
Inviato: 19.10.09 | 18:26 |
|
|
bhe la soluzione era facile....................domanda un po inutie
vabbè capita.
allora io ho risolto in questo modo, ma il risultato è che non mi crea ne la thumb e non mi carica l'immagine..................perchè?
| Codice: | <?php
//path to storage
$storage = $_REQUEST["folder"];
//path name of file for storage
$uploadfile = "$storage/" . basename( $_FILES['Filedata']['name'] );
//if the file is moved successfully
if ( move_uploaded_file( $_FILES['Filedata']['tmp_name'] , $uploadfile ) )
{
$imgSrc = $uploadfile
//getting the image dimensions
list($width, $height) = getimagesize("$storage/" . $imgSrc);
//saving the image into memory (for manipulation with GD Library)
$myImage = imagecreatefromjpeg("$storage/" . $imgSrc);
if($width > $height) $biggestSide = $width;
else $biggestSide = $height;
//The crop size will be half that of the largest side
$cropPercent = .5;
$cropWidth = $biggestSide*$cropPercent;
$cropHeight = $biggestSide*$cropPercent;
//getting the top left coordinate
$c1 = array("x"=>($width-$cropWidth)/2, "y"=>($height-$cropHeight)/2);
$thumbSize = 60;
$thumb = imagecreatetruecolor($thumbSize, $thumbSize);
imagecopyresampled($thumb, $myImage, 0, 0, $c1['x'], $c1['y'], $thumbSize, $thumbSize, $cropWidth, $cropHeight);
imagejpeg($thumb, "$storage/" . $uploadfile ."_thumb.jpg", 100);
$answer="ok";
echo "answer=".$answer;
//file failed to move
}else{
$answer="no";
echo "answer=".$answer;
}
?> |
a me serve che faccia l'upload di tale foto, tale foto una volta caricata oltre ad esserci lei deve essere creata la sua thumb.
in cosa sbaglio? ____________________________________________________________ .... |
|
| Torna in cima |
|
|
Coach
amministratore


Età: -1981
Registrato: 31/01/03 13:50
Messaggi: 4546
Località: Verona
|
Oggetto:
Inviato: 07.12.09 | 19:27 |
|
|
Più che upload, vorresti salvare l'imamgin modificata sul server?
Essendo sul server non è un upload :)
Prova a vedere se questo post può fare al caso tuo:
ridimensionamento immagini in php ____________________________________________________________
Il Forum è uno strumento di condivisione, oltre a fare DOMANDE, si possono anche dare RISPOSTE! |
|
| Torna in cima |
|
|
suns
esperto

Età: -1988
Registrato: 20/07/05 23:53
Messaggi: 537
|
Oggetto:
Inviato: 07.12.09 | 19:40 |
|
|
con la domanda di oggi ho risolto l'arcano mistero e ci son riuscito :P ecco la soluzione :
| Codice: | <?php
$storage = $_REQUEST["folder"];
$uploadfile = "$storage/" . basename( $_FILES['Filedata']['name'] );
$thumb_name = $_FILES['Filedata']['name'];
if (!move_uploaded_file( $_FILES['Filedata']['tmp_name'] , $uploadfile ) )
die("answer=no");
list($width, $height) = getimagesize($uploadfile );
$myImage = imagecreatefromjpeg($uploadfile );
if($width > $height)
{
$biggestSide = $width;
$lowestSide = $height;
}else{
$biggestSide = $height;
$lowestSide = $width;
}
$cropPercent = .5;
$cropWidth = $lowestSide*$cropPercent;
$cropHeight = $biggestSide*$cropPercent;
$c1 = array("x"=>($width-$cropWidth)/2, "y"=>($height-$cropHeight)/2);
$xThumbSize = 200;
$yThumbSize = 300;
$thumb = imagecreatetruecolor($xThumbSize, $yThumbSize);
imagecopyresampled($thumb, $myImage, 0, 0, $c1['x'], $c1['y'], $xThumbSize, $yThumbSize, $cropWidth, $cropHeight);
imagejpeg($thumb, "$storage/thumb_" . $thumb_name, 100);
echo "answer=ok";
?> |
____________________________________________________________ .... |
|
| Torna in cima |
|
|
Coach
amministratore


Età: -1981
Registrato: 31/01/03 13:50
Messaggi: 4546
Località: Verona
|
|
| Torna in cima |
|
|
|
|
Non puoi inserire nuovi Topic in questo forum Non puoi rispondere ai Topic in questo forum Non puoi modificare i tuoi messaggi in questo forum Non puoi cancellare i tuoi messaggi in questo forum Non puoi votare nei sondaggi in questo forum Non puoi allegare files in questo forum Non puoi downloadare gli allegati in questo forum
|
|