The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Upload picture to cPanel PHP/MySql

Discussion in 'Database Discussions' started by milams, Jan 3, 2007.

  1. milams

    milams Registered

    Joined:
    Jan 3, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    I'm new to cPanel forums so I'm sure if I'm asking this question in the right place. I've set up a database in MySql and I wrote a PHP script to upload pictures in to the database. The problem is that when I submit the form to upload the picture, the variable that stores the file name is blank. All of the other fields from the form submit fine and store the value into the databse fine. Can I not use [CODE<input type="file" name="pict_url" value="<?php echo $pict_url; ?>" size="50">[/CODE] to submit to the database? It works great on my local machine.

    When the form is submitted it is supposed to measure the width of the picture and if it is larger than a specified width it will go thru a script to resize the picture and then store it to the databse.

    PHP:
        if($width 400){
                
           
    // This is the temporary file created by PHP 
              
    $uploadedfile $_FILES['pict_url']['tmp_name'];
                            
                            
        
    // Create an Image from it so we can do the resize
        
    $src imagecreatefromjpeg($uploadedfile);
                            
        
    // Capture the original size of the uploaded image
                            
        
    list($width,$height)=getimagesize($uploadedfile);
                            
        
    // resize the image
                            
        
    $newwidth=400;
        
    $newheight=($height/$width)*400;
        
    $tmp=imagecreatetruecolor($newwidth,$newheight);
                        
        
    // this line actually does the image resizing, copying from the original
        // image into the $tmp image
        
    imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); 
                        
        
    // now write the resized image to disk. I have assumed that you want the
        // resized, uploaded image file to reside in the ./images subdirectory.
        
    $filename "../images/"$_FILES['pict_url']['name'];
        
    imagejpeg($tmp,$filename,100);
                            
        
    imagedestroy($src);
        
    imagedestroy($tmp);
                        

         }
    Are there some limitations using the cPanel MySQL/PHP because PHP is configured to not accept file uploads?

    Again, if I'm asking this question in the wrong place, I do apologize.

    Thanks
     
  2. tweakservers

    tweakservers Well-Known Member

    Joined:
    Mar 30, 2006
    Messages:
    379
    Likes Received:
    0
    Trophy Points:
    16
    so far I have not see any problems with our client's Cpanel box with their PHP/MySQL to upload files to the server. If you are suspecting the issues on your PHP, check your server's PHP configuration file to ensure PHP upload is turned on. Mostly, the upload function is turned on by default for any new PHP upload.
     
  3. milams

    milams Registered

    Joined:
    Jan 3, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    I had a felling the the PHP config may not have file upload might be truned off, but I can't seem to find the php.ini file on cPanel. I'm not used to cPanel so I have no idea where to look to see the ini file.
     
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,478
    Likes Received:
    203
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    /usr/local/lib/php.ini
     
  5. WEB-PROS

    WEB-PROS Well-Known Member

    Joined:
    Feb 19, 2006
    Messages:
    111
    Likes Received:
    0
    Trophy Points:
    16
    Looks as if this guy/girl only has access to Cpanel. You need to contact your host.
     
Loading...
Similar Threads - Upload picture cPanel
  1. jndawson
    Replies:
    12
    Views:
    2,167

Share This Page