Assalam-o-alaikum
Bothers main nay aik dynamic website create ki hay. us main sub kuch theik ja reha hay. her article save ho reha hay laikun images save nehan ho rehay. Aur database file main picture ka link bhi save nehain ho reha shaid issi waja say picture na to save hoti hay aur na hi load hoti hay... (FILE IS ATTACHED UNDER)
plz meri rehnmai karain.
Thanks in advance for help
Almuez
FILE IS ATTACHED
<?PHP
error_reporting(0);
//****************************************
$thumbx="150"; //X dimension of thumbnail in px
$thumby="150"; //Y dimension of thumbnail in px
$mainimx="390";//X dimension of large image in px
$mainimy="440";//Y dimension of large image in px
$bigimx="500";//X dimension of big image in px
$bigimy="500";//Y dimension of big image in px
//****************************************
function improcmain($img,$mainimx,$mainimy,$thumbx,$thumby, $prodid){
global $bigimx,$bigimy;
// mysql_query("insert into prodimgs (prodid) values ('$prodid')") or die(mysql_error());
// $imgid=mysql_insert_id();
$imgid=$prodid;
$base_img_dir = "../../prodimages/";
$base_thumb_dir = "../../prodimages/Thumbs/";
$base_bigim_dir = "../../prodimages/bigim/";
imageresize ($img,$mainimx,$mainimy,$imgid,$base_img_dir);
imageresize ($img,$thumbx,$thumby,$imgid,$base_thumb_dir);
imageresize ($img,$bigimx,$bigimy,$imgid,$base_bigim_dir);
imagedestroy($img);
return($imgid);
}
function imageresize($img, $maxwidth, $maxheight, $imgid,$base_img_dir){
$width = imagesx($img);
$height = imagesy($img);
$scale = min($maxwidth/$width, $maxheight/$height);
if ($scale < 1) {
$new_width = floor($scale*$width);
$new_height = floor($scale*$height);
$tmp_img = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
$img = $tmp_img;
}
$filename=$base_img_dir.$imgid.".jpg";
imagejpeg($img, $filename, 100);
}
function getuploads($prodid,$mainimx,$mainimy,$thumbx,$thum by){
while (list($key,$val)=each($_FILES)){
$file_name=str_replace("'","",stripslashes($_FILES[$key]['name']));
if ($file_name){
$tmp_name=$_FILES[$key]['tmp_name'];
$imginfo= @getimagesize($tmp_name);
switch ($imginfo[2]) {
case 1: //gif
$img=imagecreatefromgif($tmp_name);
$imgid=improcmain($img,$mainimx,$mainimy,$thumbx,$ thumby,$file_name);
break;
case 2: //jpg
$img=imagecreatefromjpeg($tmp_name);
$imgid=improcmain($img,$mainimx,$mainimy,$thumbx,$ thumby,$file_name);
break;
case 3: //png
$img=imagecreatefrompng($tmp_name);
$imgid=improcmain($img,$mainimx,$mainimy,$thumbx,$ thumby,$file_name);
break;
default:
break;
}
}
}
return($file_name);
// print "All images successfully uploaded. You can now close this window.";
}
if ($_POST['id']!='' or $_GET['isupload']){
function drawupload($optionid,$image){
$base_img_dir = "prodimages/";
$base_thumb_dir = "prodimages/Thumbs/";
?>
<script language="javascript" type="text/javascript">
function upload(){
document.imageform.submit();
document.getElementById('uploadbody').innerHTML='
<img src=".. /../images/indicator.gif"><span valign=middle style="font:12px Verdana,Arial,Helvetica Sans-Serif;"> Please wait - uploading</span>';
}
</script>
<form name="imageform" action="ajaxim.php" method="post" enctype="multipart/form-data"><div id="uploadbody">
<input type=hidden id="id" name="id" value="<?php echo $optionid; ?>">
<input type="file" name="image" onchange="upload();"/>
</div><?php if ($image and $image!='.jpg') {
echo "<img src=\"../../prodimages/Thumbs/$image\">";
?><input type=button value="Delete image" name="Delete" onclick="upload();">
<?php
}?></form>
<script language="javascript" type="text/javascript">
function updateimageform(){
parent.document.getElementById('pLargeImage').valu e='<? if ($image=='.jpg') {echo "";} else echo $base_img_dir.$image;?>';
parent.document.getElementById('pImage').value='<? if ($image=='.jpg') {echo "";} else echo $base_thumb_dir.$image;?>';}
onLoad=updateimageform();
</script>
<?php
}}
if ($_POST['id']!=''){
$id=$_POST['id'];
$file_name=getuploads($id,$mainimx,$mainimy,$thumb x,$thumby);
// include("../db_conn_open.php");
// mysql_query("update products set optAJAXIM='$file_nameshort' where optID='$id'") or die(mysql_error());
// $ogrpq=mysql_query("select optGroup from options where optID='$id'") or die(mysql_error());
// $ogrp=mysql_result($ogrpq,0,0);
// mysql_query("update prodoptions set poAJAXIM='1' where poOptionGroup='$ogrp'") or die(mysql_error());
drawupload($id,$file_name.".jpg");
}
$isupload=$_GET['isupload'];
if ($isupload) {
$optionid=$_GET['productid'];
if ($optionid!='' && $optionid!='undefined'){
include("../db_conn_open.php");
$imager=@mysql_query("select pImage from products where pID='$optionid'");
$image=@mysql_result($imager,0,0);
$imagestripped=split("/",$image);
$last=count($imagestripped);
$image=$imagestripped[($last-1)];
drawupload($optionid,$image);
}
else { echo "<span style=\"color: red; font:12px Verdana,Arial,Helvetica Sans-Serif;font-weight:bold;\"><br><br><br><br><br><br>Please enter a Reference/Product ID in order to activate the image selector.</span>"; }
}
?>
Bothers main nay aik dynamic website create ki hay. us main sub kuch theik ja reha hay. her article save ho reha hay laikun images save nehan ho rehay. Aur database file main picture ka link bhi save nehain ho reha shaid issi waja say picture na to save hoti hay aur na hi load hoti hay... (FILE IS ATTACHED UNDER)
plz meri rehnmai karain.
Thanks in advance for help
Almuez
FILE IS ATTACHED
<?PHP
error_reporting(0);
//****************************************
$thumbx="150"; //X dimension of thumbnail in px
$thumby="150"; //Y dimension of thumbnail in px
$mainimx="390";//X dimension of large image in px
$mainimy="440";//Y dimension of large image in px
$bigimx="500";//X dimension of big image in px
$bigimy="500";//Y dimension of big image in px
//****************************************
function improcmain($img,$mainimx,$mainimy,$thumbx,$thumby, $prodid){
global $bigimx,$bigimy;
// mysql_query("insert into prodimgs (prodid) values ('$prodid')") or die(mysql_error());
// $imgid=mysql_insert_id();
$imgid=$prodid;
$base_img_dir = "../../prodimages/";
$base_thumb_dir = "../../prodimages/Thumbs/";
$base_bigim_dir = "../../prodimages/bigim/";
imageresize ($img,$mainimx,$mainimy,$imgid,$base_img_dir);
imageresize ($img,$thumbx,$thumby,$imgid,$base_thumb_dir);
imageresize ($img,$bigimx,$bigimy,$imgid,$base_bigim_dir);
imagedestroy($img);
return($imgid);
}
function imageresize($img, $maxwidth, $maxheight, $imgid,$base_img_dir){
$width = imagesx($img);
$height = imagesy($img);
$scale = min($maxwidth/$width, $maxheight/$height);
if ($scale < 1) {
$new_width = floor($scale*$width);
$new_height = floor($scale*$height);
$tmp_img = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
$img = $tmp_img;
}
$filename=$base_img_dir.$imgid.".jpg";
imagejpeg($img, $filename, 100);
}
function getuploads($prodid,$mainimx,$mainimy,$thumbx,$thum by){
while (list($key,$val)=each($_FILES)){
$file_name=str_replace("'","",stripslashes($_FILES[$key]['name']));
if ($file_name){
$tmp_name=$_FILES[$key]['tmp_name'];
$imginfo= @getimagesize($tmp_name);
switch ($imginfo[2]) {
case 1: //gif
$img=imagecreatefromgif($tmp_name);
$imgid=improcmain($img,$mainimx,$mainimy,$thumbx,$ thumby,$file_name);
break;
case 2: //jpg
$img=imagecreatefromjpeg($tmp_name);
$imgid=improcmain($img,$mainimx,$mainimy,$thumbx,$ thumby,$file_name);
break;
case 3: //png
$img=imagecreatefrompng($tmp_name);
$imgid=improcmain($img,$mainimx,$mainimy,$thumbx,$ thumby,$file_name);
break;
default:
break;
}
}
}
return($file_name);
// print "All images successfully uploaded. You can now close this window.";
}
if ($_POST['id']!='' or $_GET['isupload']){
function drawupload($optionid,$image){
$base_img_dir = "prodimages/";
$base_thumb_dir = "prodimages/Thumbs/";
?>
<script language="javascript" type="text/javascript">
function upload(){
document.imageform.submit();
document.getElementById('uploadbody').innerHTML='
<img src=".. /../images/indicator.gif"><span valign=middle style="font:12px Verdana,Arial,Helvetica Sans-Serif;"> Please wait - uploading</span>';
}
</script>
<form name="imageform" action="ajaxim.php" method="post" enctype="multipart/form-data"><div id="uploadbody">
<input type=hidden id="id" name="id" value="<?php echo $optionid; ?>">
<input type="file" name="image" onchange="upload();"/>
</div><?php if ($image and $image!='.jpg') {
echo "<img src=\"../../prodimages/Thumbs/$image\">";
?><input type=button value="Delete image" name="Delete" onclick="upload();">
<?php
}?></form>
<script language="javascript" type="text/javascript">
function updateimageform(){
parent.document.getElementById('pLargeImage').valu e='<? if ($image=='.jpg') {echo "";} else echo $base_img_dir.$image;?>';
parent.document.getElementById('pImage').value='<? if ($image=='.jpg') {echo "";} else echo $base_thumb_dir.$image;?>';}
onLoad=updateimageform();
</script>
<?php
}}
if ($_POST['id']!=''){
$id=$_POST['id'];
$file_name=getuploads($id,$mainimx,$mainimy,$thumb x,$thumby);
// include("../db_conn_open.php");
// mysql_query("update products set optAJAXIM='$file_nameshort' where optID='$id'") or die(mysql_error());
// $ogrpq=mysql_query("select optGroup from options where optID='$id'") or die(mysql_error());
// $ogrp=mysql_result($ogrpq,0,0);
// mysql_query("update prodoptions set poAJAXIM='1' where poOptionGroup='$ogrp'") or die(mysql_error());
drawupload($id,$file_name.".jpg");
}
$isupload=$_GET['isupload'];
if ($isupload) {
$optionid=$_GET['productid'];
if ($optionid!='' && $optionid!='undefined'){
include("../db_conn_open.php");
$imager=@mysql_query("select pImage from products where pID='$optionid'");
$image=@mysql_result($imager,0,0);
$imagestripped=split("/",$image);
$last=count($imagestripped);
$image=$imagestripped[($last-1)];
drawupload($optionid,$image);
}
else { echo "<span style=\"color: red; font:12px Verdana,Arial,Helvetica Sans-Serif;font-weight:bold;\"><br><br><br><br><br><br>Please enter a Reference/Product ID in order to activate the image selector.</span>"; }
}
?>
Comment