Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Images

Problem uploading images to the database

images php coding issues or problems here.

Moderators: macek, egami, gesf

Problem uploading images to the database

Postby certified4future » Thu Sep 06, 2012 11:41 am

Hello Friends , I have written the following code to upload images to my database , I am using WAMP as my local server , My code worked just the first time and did not work anymore , it is giving me the following error " Maximum width and height exceeded. Please upload images below 100x100px size " , here is the code :

Code: Select all
<?php
$con=mysql_connect("localhost","saideh"); 
if(!$con)
{
die ('MySQL connect error !');

if(!mysql_select_db('movie galaxy',$con))
{
die('MySQL database select error !');

$iSize = 1000000000; 
$iWidth = 6000000;
$iHeight = 6000000; 
if((isset($_FILES["image"])) && ($_FILES["image"]["size"] > 0))
{
$imgSize = $_FILES["image"]["size"];
$imgType = $_FILES["image"]["type"];
$tmpName = $_FILES["image"]["tmp_name"];   
if($imgSize > $iSize)
exit("Error: Large file size.");   
$getImgSize = getimagesize($tmpName);   
if(!$getImgSize){
exit("Error: Invalid Image File.");}   
list($width, $height) = $getImgSize;   
if(($width > $Width) || ($height > $iHeight))
exit("Maximum width and height exceeded. Please upload images below 100x100px size");   
$fp = fopen($tmpName, 'r');
$imageName = fread($fp, filesize($tmpName));   
$imageName = addslashes($imageName);   
fclose($fp);   
$w=$_POST["fcode"];
$query ="UPDATE `movie galaxy`.`film` SET(`imgType`='$imgType',`imgImage`='$imageName',`imgSize='$imgSize')WHERE(`fcode`='$w')";
 
 //$query = "INSERT INTO `film` (`imgType`, `imgImage`, `imgSize`) VALUES ('$imgType', '$imageName', '$imgSize')";
$sql=mysql_query($query);
die ('تصویر وارد بانک شد !');
 }
   
?>



here is the html code :
Code: Select all
</div>
 <form method="post" action="insertpic.php" enctype="multipart/form-data">
 کدفیلم <br/><input type="text" name="fcode" /><br />
عکس <input name="image" type="file" />
 <input type="submit" value="submit" />
 </form>

Please help me ...
certified4future
New php-forum User
New php-forum User
 
Posts: 1
Joined: Thu Sep 06, 2012 11:32 am

Return to PHP coding => Images

Who is online

Users browsing this forum: No registered users and 0 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.