imagecreatefromjpeg function in php returns nothing
<p>Hi 
I am working on a piece of code these days where user uploads image and those images are displayed on the home page. Call to a function couponUpload is made in which all the image manipulation is done, in this function am using "imagecreatefromjpeg" but its not returning any value and php doesnt  execute the code after this line, its like control gets stuck in this "imagecreatefromjpeg" forever, am passing path in the function and when echoed the path is displayed(usually /tmp/233232.jpg). Please help.</p>

<pre><code>$function couponUpload()
{



    include "docroot.php";
    $cname=htmlentities($_POST['couponname'], ENT_QUOTES);
    $cdesc=htmlentities($_POST['cdesc'], ENT_QUOTES);
    $cfineprints=htmlentities($_POST['cfineprints'], ENT_QUOTES);
    $chighlights=htmlentities($_POST['chighlights'], ENT_QUOTES);
    $cstartdate=htmlentities($_POST['cstartdate']);
    $cenddate=htmlentities($_POST['cenddate']);
    $climit=htmlentities($_POST['climit']);
    $cterms=htmlentities($_POST['cterms']);
    $coffer=htmlentities($_POST['coffer']);
    $cminuser=htmlentities($_POST['minlimit']);
    $cmaxuser=htmlentities($_POST['maxlimit']);
    $crealvalue=htmlentities($_POST['crealvalue']);
    $cperson=htmlentities($_POST['cperson'], ENT_QUOTES);
    $phonenum=htmlentities($_POST['phonenum']);
    $address=htmlentities($_POST['address'], ENT_QUOTES);
        if($_POST['couponname']=='' || $_POST['cdesc']=='' || $_POST['crealvalue']=='' || $_POST['crealvalue']==0)
        {
        $redirect_url = DOCROOT."admin/couponsupload/";
        set_response_mes(1,'All fields are mandatory.');    
        url_redirect($redirect_url);
        }

    $uid=$_SESSION["userid"];
    $shopid=$_POST['shop'];
    $csubtype=$_POST['csubtype'];
    $ctype=$_POST['ctype'];
    $country = $_POST['country'];
    $city=$_POST['city'];

    $randomvalue=ranval();
if ($_FILES['cpicture']['type'] == "image/jpeg"||$_FILES['cpicture']['type'] == "image/jpg"||$_FILES['cpicture']['type'] == "image/gif"||$_FILES['cpicture']['type'] == "image/png"||$_FILES['cpicture']['type'] == "image/pjpeg")
{





    if(isset($_FILES['cpicture'])) 
    {


        try 
        {         
            $imgData =addslashes (file_get_contents($_FILES['cpicture']['tmp_name']));
            $size = getimagesize($_FILES['cpicture']['tmp_name']);
            $userid = $_SESSION["userid"];
            $imtype = $_FILES['cpicture']['type'];

            $path= $_FILES['cpicture']['tmp_name'];
    //$twidth = "330";   // Maximum Width For Thumbnail Images
    //$theight = "281";   // Maximum Height For Thumbnail Images 

            switch ($size['mime'])
            {
                case 'image/gif':
                $im = imagecreatefromgif($_FILES['cpicture']['tmp_name']);
                break;

                case 'image/jpeg':
                echo "here";
                $im = imagecreatefromjpeg($path);
                echo "another here";
                break;

                case 'image/png':
                $im = imagecreatefrompng($_FILES['cpicture']['tmp_name']);
                echo "papa";    
                break;
            };

                $width = imagesx($im);
                $height = imagesy($im);


            $newwidthX=420;
                    $newheightX=($height/$width)*$newwidthX;
                    if($newheightX &gt;285)
                    {
                    $newheight=285;
                    $newwidth=($newwidthX/$newheightX)*$newheight;
                    } 
                    else 
                    {
                    $newheight = $newheightX;
                    $newwidth = $newwidthX; 
                    } 



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

                ImageCopyResampled($thumb,$im,0,0,0,0,$newwidth,$newheight,ImageSX($im),ImageSY($im));


              Imagejpeg($imgData,"uploads/coupons/".$randomvalue.".jpg");
                Imagejpeg($imgData);
                                $imgurl="uploads/coupons/".$randomvalue.".jpg";



        }
            catch(Exception $e)

            {
            }

    }
}
</code></pre>
