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
https://forums.phpfreaks.com/topic/253602-getting-blank-temp_name-in-image-upload/
Share on other sites

Thanks for your resposnce ......  No, i'm not getting any of the error, it may be because i'm working in zen cart and there exist any restrictions to show errors... if  you have any idea about showing errors then tell me !

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.