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.
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
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);
}
Again, if I'm asking this question in the wrong place, I do apologize.
Thanks