Jump to content

getting blank 'temp_name' in image upload


ankitagupta3188

Recommended Posts

I'm working in my site which is in zen cart, actually a want to add a little fuctionality on it, and that is.... When i upload a image for a product i also want to create a thumbnail size of that image to be in a folder. Now i tried to search a file where the code to upload image goes on.. i found a file in htdocs/admin_folder/includes/modules/new_product_preview.php

 

Now after getting details from user from a page htdocs/admin_folder/product.php it form post it in new_product_review.php page with a action defind in it and here the code for uploading image i've just simply added code as follows but it is not uploading the image in folder.

 

I've tried to echo the name of the file, so i've just put the alert for the image name parameters, i'm getting the $_FILES["products_image"]["tmp_name"] as something like, /tmp/gsnVaX.. like but when i check $_FILES["products_image"]["name"] it gives the correct name of the file...

 

why its not putting the image in temporary folder ? when i put the resize code on it then it saves image in my folder with the same size which i wanted but whole image is just blank black. Code is

 

$image = "../images/thumbs/anki_".$_FILES["products_image"]["name"];

move_uploaded_file($_FILES["products_image"]["tmp_name"],$image);

and code when i'm doing this through resize is-

 

                    $control = "products_image";

        $fileName = $_FILES[$control]['name'];

        $uploadedfile = $_FILES[$control]['tmp_name'];

        echo "<script>alert('".$fileName."');</script>";

        $exts = explode(".",$fileName);

        $ext = array_pop($exts);

        $uploadedfile = $_FILES[$control]['name'];

        $extension = $ext;

        $extension = strtolower($extension);

        if($extension=="jpg" || $extension=="jpeg" )

        {

            $src = imagecreatefromjpeg($uploadedfile);

        }

        else if($extension=="png")

        {

            $src = imagecreatefrompng($uploadedfile);

        }

        else

        {

            $src = imagecreatefromgif($uploadedfile);

        }

 

        $newwidth = 140;

 

        list($width,$height)=getimagesize($uploadedfile);

        $newheight=($height/$width)*$newwidth;

        $newheight = 135;

        $tmp=imagecreatetruecolor($newwidth,$newheight);

                imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);

        $filename = "../images/thumbs/". $fileName;

        imagejpeg($tmp,$filename,100);

        imagedestroy($src);

        imagedestroy($tmp);

 

Please suggest me what i'm doing wrong with it its very urgent please help me out from this...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.