Grow your CSS skills. Land your dream job.

php error while uploading image

  • # June 10, 2009 at 5:04 pm

    please can anyone help me sort this prob out. i have this sample which is use to upload image and load it at the same time. but it keeps given me error message. "Notice: Undefined index: image in c:inetpubwwwrootglisfinanceTESTupload.php on line 10

    Notice: Undefined index: image in c:inetpubwwwrootglisfinanceTESTupload.php on line 11

    Notice: Undefined index: image in c:inetpubwwwrootglisfinanceTESTupload.php on line 14
    "
    here are the code below. there are three files, one imade_upload.php, upload.php and resize.php

    Code:
    < ?php
    /********************************************************************************************************************************
    PHPAsks.com
    Developed by Asif Khalyani
    Email : asif.khalyani@msn.com

    ********************************************************************************************************************************/
    ?>


    PHPAsks.com

    Power by PHPAsks.com


    Code:
    < ?php
    /********************************************************************************************************************************
    PHPAsks.com
    Developed by Asif Khalyani
    Email : asif.khalyani@msn.com

    ********************************************************************************************************************************/

    sleep(2);
    $ftmp = $_FILES['image']['tmp_name'];
    $oname = $_FILES['image']['name'];

    $extenssion = strstr($oname, ".");
    $fname = 'upload/'.$_FILES['image']['name'];
    if(move_uploaded_file($ftmp, $fname)){
    ?>


    < ?php
    exit();
    }
    ?>



    Code:
    < ?php
    /********************************************************************************************************************************
    PHPAsks.com
    Developed by Asif Khalyani
    Email : asif.khalyani@msn.com

    ********************************************************************************************************************************/
    if($_GET['pic']){
    $img = new img('upload/'.$_GET['pic']);
    $width = $_GET["width"];
    $height = $_GET["height"];
    $img->resize();
    $img->show();
    }

    class img {

    var $image = ”;
    var $temp = ”;

    function img($sourceFile){
    if(file_exists($sourceFile)){
    $this->image = ImageCreateFromJPEG($sourceFile);
    } else {
    $this->errorHandler();
    }
    return;
    }

    function resize($width = 100, $height = 100, $aspectradio = true){
    $o_wd = imagesx($this->image);
    $o_ht = imagesy($this->image);
    if(isset($aspectradio)&&$aspectradio) {
    $w = round($o_wd * $height / $o_ht);
    $h = round($o_ht * $width / $o_wd);
    if(($height-$h)< ($width-$w)){
    $width =& $w;
    } else {
    $height =& $h;
    }
    }
    $this->temp = imageCreateTrueColor($width,$height);
    imageCopyResampled($this->temp, $this->image,
    0, 0, 0, 0, $width, $height, $o_wd, $o_ht);
    $this->sync();
    return;
    }

    function sync(){
    $this->image =& $this->temp;
    unset($this->temp);
    $this->temp = ”;
    return;
    }

    function show(){
    $this->_sendHeader();
    ImageJPEG($this->image);
    return;
    }

    function _sendHeader(){
    header(‘Content-Type: image/jpeg’);
    }

    function errorHandler(){
    echo “error”;
    exit();
    }

    function store($file){
    ImageJPEG($this->image,$file);
    return;
    }

    function watermark($pngImage, $left = 0, $top = 0){
    ImageAlphaBlending($this->image, true);
    $layer = ImageCreateFromPNG($pngImage);
    $logoW = ImageSX($layer);
    $logoH = ImageSY($layer);
    ImageCopy($this->image, $layer, $left, $top, 0, 0, $logoW, $logoH);
    }
    }
    ?>

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".