Problema upload immagini! HELP!

nikit0

Nuovo Utente
3 Mar 2008
4
0
0
Ciao a tutti io ho un file (carphoto.php) che dovrebbe far fare l'upload in una cartella specifica ed infatti lo fa solo che poi da quella cartella specifica dovrebbe far posizionare la foto dove decido io di stamparla!! ed invece non lo fa! fra l'altro quando eseguo la pagina rimane tutto bianco e non mi da nessun errore solo che rimane bianco..... posto il codice!
codice PHP:
PHP:
<?php
session_start();
include_once("config.php");
include_once("session.php");
include_once("nav.php");
if(!VerifySession()){
    header("location:login.php");
}
$hidaction=getVal('do');
$cid=getVal(cid);
$image_id=getVal(image_id);
eval("\$display = \"".$Template->GetTemplate("leftside")."\";");
$CarInfo->sortby = $sortbyvar;
$CarInfo->cid=$cid;
$CarInfo->cLoad();
if ($CarInfo->owner_id != $_SESSION['oid']){
    $Message = "<span style=\"color:red; font-weight:bold\"><br />$NoPermissions<br /></span>\n";
    eval("\$display .= \"".$Template->GetTemplate("error_msg_close")."\";");
    eval("\$footer = \"".$Template->GetTemplate("footer")."\";");
    eval("\$main = \"".$Template->GetTemplate("main")."\";");
    $Template->ProcessTemplate($main);
    exit;
}
$CarInfo->Load();
if($hidaction=="addphoto")
{
    $ctrP=0;
    foreach($_FILES['pics'] as $pics)
    {
        if($_FILES['pics']['name'][$ctrP]<>"")
        {
            if(is_uploaded_file($_FILES['pics']['tmp_name'][$ctrP]) or die("No Image: ".$_FILES['pics']['name'][$ctrP]))
            {
                $ext = substr(strrchr($_FILES['pics']['name'][$ctrP],"."),1);
                //$pieces = explode(".", $_FILES['pics']['name'][$ctrP]);
                //$ext = $pieces[count($pieces) - 1];
                if ((in_array($ext, $types_array)) AND ($_FILES['pics']["size"][$ctrP]<(MAXFILE_SIZE * 1000)))
                {
                    $orgImageName="cid".$property_id."_".str_replace(" ","_",$_FILES['pics']['name'][$ctrP]);
                    $thmImageName="thumb_cid".$property_id."_".str_replace(" ","_",$_FILES['pics']['name'][$ctrP]);
                    $dtlImageName="dtl_cid".$property_id."_".str_replace(" ","_",$_FILES['pics']['name'][$ctrP]);

                    if(move_uploaded_file($_FILES['pics']['tmp_name'][$ctrP],NEWPICPATH."/".$orgImageName) or die("error on moving"))
                    {
                        # Get image location
                        $image_path = NEWPICPATH."/".$orgImageName;
                        //echo $image_path;
                        # Load image
                        $img = null;
                        $main_img=null;
                        $thumb_img=null;
                        $dtl_img=null;                                    
                        $size = @getimagesize($image_path);
                        $scale = min(MAXIMAGE_W_SIZE/$size[0], MAXIMAGE_H_SIZE/$size[1])
                        # If the image is larger than the max shrink
                        if($scale<1) {
                           $i = .9;
                           do {
                               $dtlW = floor($i*$size[0]);
                               $dtlH = floor($i*$size[1]);
                               $i = $i - .05;
                            } while ($dtlW >= MAXIMAGE_W_SIZE);
                        } else {
                           $dtlW = $size[0];
                            $dtlH = $size[1];
                        }
                         $i = 0;
                           do {
                               $thumbW = floor($i*$size[0]);
                               $thumbH = floor($i*$size[1]);
                               $i = $i + .05;
                            } while ($thumbW <= LOWESTIMAGE_W_SIZE);
                        //$ext = strtolower(end(explode('.', $image_path)));
                        if ($ext == 'jpg' || $ext == 'jpeg' || $ext == 'pjpeg') {
                            $img = @imagecreatefromjpeg($image_path);
                        } else if ($ext == 'png') {
                            $img = @imagecreatefrompng($image_path);
                        # Only if your version of GD includes GIF support
                        } else if ($ext == 'gif') {
                            $img = @imagecreatefromgif($image_path);
                        }
                        # If an image was successfully loaded, test the image for size
                        if ($img) {
                            # Get image size and scale ratio
                            $width = imagesx($img);
                            $height = imagesy($img);
                            # Create a new temporary image
                            $thumb_img = imagecreatetruecolor($thumbW, $thumbH);
                            $dtl_img = imagecreatetruecolor($dtlW, $dtlH);                                        
                            # Copy and resize old image into new image
                            ImageCopyResampled($thumb_img, $img, 0, 0, 0, 0,$thumbW, $thumbH, $width, $height);
                            ImageCopyResampled($dtl_img, $img, 0, 0, 0, 0,$dtlW, $dtlH, $width, $height);                
                            # Copy and resize old image into new image
                            imagedestroy($img);
                        }  //end of if $img
                        # Display the image
                        if ($ext == 'jpg' || $ext == 'jpeg' || $ext == 'pjpeg') {
                            imagejpeg($thumb_img,THUMBPICPATH."/".$thmImageName);
                            imagejpeg($dtl_img,DTLPICPATH."/".$dtlImageName);
                        } else if ($ext == 'png') {
                            imagepng($thumb_img,THUMBPICPATH."/".$thmImageName);
                            imagepng($dtl_img,DTLPICPATH."/".$dtlImageName);
                        # Only if your version of GD includes GIF support
                        } else if ($ext == 'gif') {
                            imagegif($thumb_img,THUMBPICPATH."/".$thmImageName);
                            imagegif($dtl_img,DTLPICPATH."/".$dtlImageName);
                        }
                        imagedestroy($thumb_img);
                        imagedestroy($dtl_img);                                            
                        //insert into db
                        $CarInfo->cid=$cid;
                        $CarInfo->image_path=$orgImageName;
                        $CarInfo->InsertImage();
                    //
                    } //end of if moveuploaded file
                } // end of if in_array
                else {
                $error .= "Invalid image: {$_FILES['pics']['name'][$ctrP]}<br />";
                }
            }  //end of if is_uploaded_file
            else {
                $error .= "No image: {$_FILES['pics']['name'][$ctrP]}<br />";
                }
        } // end of if pics name is not empty string
        $ctrP++;
    } //end of for each

    if (!$error){
        $display .="<META HTTP-EQUIV=\"Refresh\" Content=\"1;URL=carphoto.php?cid=$cid\">";
        eval("\$footer = \"".$Template->GetTemplate("footer")."\";");
        eval("\$main = \"".$Template->GetTemplate("main")."\";");
        $Template->ProcessTemplate($main);
        exit;
     } else {
        $hidaction=="add";
     }
}
if($hidaction=="delete"){
    $CarInfo->cid=$cid;
    $CarInfo->image_id=$image_id;
    $CarInfo->DeletePhoto();
    $error = $CarInfo->msg;
}
if($hidaction=="add"){

    for($i=0;$i<5;$i++){
        $imagerow .=<<<PHOTO
              <tr>
                <td style="height:33px"><input type="file" name="pics[]" size="70" class="tinput" /></td>
              </tr>
PHOTO;
         }
    if ($CarInfo->listed_by == 'S'){
    $HeaderImage = "<img src=\"images/title_seller-editcarimg.gif\" width=\"210\" height=\"14\" alt=\"\" title=\"\" />";
} elseif ($CarInfo->listed_by == 'D'){
    $HeaderImage = "<img src=\"images/title_dealer-editcarimg.gif\" width=\"210\" height=\"14\" alt=\"\" title=\"\" />";
}
    eval("\$display .= \"".$Template->GetTemplate("carimageform")."\";");
    eval("\$footer = \"".$Template->GetTemplate("footer")."\";");
    eval("\$main = \"".$Template->GetTemplate("main")."\";");
    $Template->ProcessTemplate($main);
    exit;
}
// default listing below
$Navi =& new PageNation();
    $Navi->Ofs = $_GET["ofs"];
    $Navi->Pgx = $pagenum;
    $Navi->PerPg = $listings_per_page;
    if ($CarInfo->NumRows){
        $Navi->AllLinks = $CarInfo->NumRows;
        $Navi->AdminPaging();
    }
$CarInfo->Limit=$limit;
$CarInfo->offset=$offset;
$CarInfo->ListPhotos();
$res=$CarInfo->result;
$numrows=$CarInfo->NumRows;
if ($CarInfo->listed_by == 'S'){
    $HeaderImage = "<img src=\"images/title_seller-currentcarimg.gif\" width=\"210\" height=\"14\" alt=\"\" title=\"\" />";
} elseif ($CarInfo->listed_by == 'D'){
    $HeaderImage = "<img src=\"images/title_dealer-currentcarimg.gif\" width=\"210\" height=\"14\" alt=\"\" title=\"\" />";
}
if($CarInfo->NumRows){
    if($res != ""){
        $str=explode(",",$res);
        $cnt=0;
        $end=count($str);
        for($i=0; $i<$end; $i++){
            $image_id=$str[$i];
            $CarInfo->image_id=$str[$i];
            $CarInfo->LoadPhoto();
            $image_path=$CarInfo->image_path;
            $thumb_image=$CarInfo->thumb_image;
            $filepath=THUMBPICURL."/".$thumb_image; //image path for the thumbnail
            //echo NEWPICPATH."/".$image_path;
            if(file_exists(NEWPICPATH."/".$image_path)){  //get the height,width of the original pic
                list($width, $height, $type, $attr) = getimagesize(NEWPICPATH."/".$image_path);
            }
            if ( file_exists(THUMBPICPATH."/".$thumb_image) ){
                $width = $width + 30;
                $height =$height + 30;
                $Image = "<a href=\"java-script:openWindow('popup.php?photo_name=$image_path', '$width', '$height');\">";
                $Image .= "<img src=\"$filepath\"></a>\n";
            }else{
                $Image = "<span class=\"txt_content03\">$ImageNotAvailable</span>\n";
            }
            eval("\$photo_listing .= \"".$Template->GetTemplate("carphoto_middle")."\";");
        }
    }
} //end of numrows
eval("\$display .= \"".$Template->GetTemplate("carimagelist")."\";");
eval("\$footer = \"".$Template->GetTemplate("footer")."\";");
eval("\$main = \"".$Template->GetTemplate("main")."\";");
$Template->ProcessTemplate($main);
?>
 
Discussioni simili
Autore Titolo Forum Risposte Data
N [PHP] Problema upload immagini wordpress PHP 2
Rikk73 Problema upload immagini PHP 4
F Problema con upload di immagini che superano 2MB PHP 14
A Problema con Upload immagini PHP 9
A problema con upload immagini multiple PHP 0
N problema script php mysql multi upload immagini PHP 31
A upload immagini problema PHP 3
G Problema con upload immagini e IE7 PHP 6
C problema upload immagini grandi con 4images Programmazione 0
L [PHP] problema con upload e javascript (upload multiplo) Javascript 2
C [PHP] Problema upload file (multiplo) PHP 1
R Problema upload file PHP 1
R Problema upload PHP 1
P Problema con lettura filesystem del client da server! Upload multiplo foto. PHP 5
francesco7 [Problema] esecuzione script Upload file in php PHP 0
L classe upload [Problema cartella] PHP 1
B Problema upload delle foto PHP 1
L problema upload: Strict Standards: Only PHP 2
F Problema con upload di file PHP 1
B Problema upload application/x-zip-compressed diventa erroneamente application/octet-stream PHP 0
L problema ftp upload su host windows PHP 9
N Problema upload iis7 Classic ASP 0
helpdesk Problema Upload non ridimensiona l'immagine PHP 4
B problema upload file PHP 3
C Problema nell'upload di un file PHP 4
R problema upload PHP 9
P Problema upload file PHP 2
V Problema con Pure Asp Upload Classic ASP 4
Y problema nell'upload di un'immagine PHP 7
S Problema upload immagine Classic ASP 4
D Problema nome file su upload Classic ASP 5
F Problema Upload file con Internet Explorer PHP 29
SolidSnake4 problema upload PHP 1
S Problema Dominio su Tiscali e upload con ADSL ALICE Domini 1
U Problema script upload file... :'( PHP 7
D problema con upload [Era: info] PHP 13
M Problema con l'upload PHP 0
V Problema Upload PHP 6
I Sto progettando nuovi siti utilizzando bootstrap e devo dire funziona bene, l'unico problema e la maschera -moz- HTML e CSS 0
K Problema form update PHP 2
O problema con dvr dahua xvr5116 IP Cam e Videosorveglianza 0
S Problema nel ciclare un json Javascript 0
G Problema con Xampp Web Server 1
andrea barletta Problema con miniature comandi Photoshop 0
I problema con alice Posta Elettronica 0
K Problema Inner join PHP 1
F firefox problema http Linux e Software 0
N Problema con position absolute e overflow HTML e CSS 4
E Problema jquery Success jQuery 2
L Problema con inner join PHP 11

Discussioni simili