windows localhost: picture upload problem
Posted: Mon Oct 30, 2006 9:04 am
feyd | Please use
I think it may be the php.ini or with the uploadimg folder permission but I have no idea what to touch.
Any idea would be welcomed!
Thank you!
Luca
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi all,
I am trying to make work locally a site which is online and working.
Both online and locally I use php 4.4.1 and mysql 3.23.58 (server in Linux, local WinXp).
While all seems working, I have a problem with this line not working locally.
When I try to upload a picture I get the "Sorry, upload picture failed" error (in the code below):Code: Select all
function UploadPic($MAX_FILE_SIZE,$filename,$file,$ECardRoot_W,$db)
{
global $apartmentid;
$fn=$_FILES[$filename]['name'];
$type=trim($_FILES[$filename]['type']);
$fnExtName=trim(substr($fn,strrpos($fn,".")));
$fnExtNameLower=strtolower($fnExtName);
//this is Firefox and IE all OK!
if(!ereg("\.(jpg|gif|png|JPG|GIF|PNG)$",$fn))
{
echo ("Sorry! Only jpg, gif, png extensions are supported! Please convert your pictures to one of this formats");
exit;
}
$size=$_FILES[$filename]['size'];
if ($size>$MAX_FILE_SIZE)
{
$systeminfo="Sorry, your picture exceeds the limitation : ".($MAX_FILE_SIZE/1024)." Please use a smaller one<br><P><INPUT TYPE=\"button\" VALUE=\"< Go Back\"
onClick=\"history.back()\">";
$db->errorRpt($systeminfo);
}
$newfn="Apartment".date(y).date(m).date(d).rand();
$newfntb=$newfn."big".$fnExtNameLower;
$newfn=$newfn.$fnExtNameLower;
if (!is_dir($ECardRoot_W))
{
mkdir($ECardRoot_W, 0777);
}
if (!copy($_FILES[$filename]['tmp_name'],$ECardRoot_W."/".$newfntb))
{
$systeminfo="Sorry, upload picture failed<br><P><INPUT TYPE=\"button\" VALUE=\"< Go Back\"
onClick=\"history.back()\">";
$db->errorRpt($systeminfo);
}
//resize
$tx=GetImageSize($ECardRoot_W."/".$newfntb);
if($tx[0]<=$tx[1] and $tx[1]>=100){
$height=100;
$width=intval($height*$tx[0]/$tx[1]);
}
if($tx[0]>=$tx[1] and $tx[0]>=100){
$width=100;
$height=intval($width*$tx[1]/$tx[0]);
}
if($tx[0]<100 and $tx[1]<100){
$width=$tx[0];
$height=$tx[1];
}
function makethumb2($srcFile,$dstFile,$dstW,$dstH){
$data=GetImageSize($srcFile,&$info);
switch($data[2]){
case 1:
$im=@ImageCreateFromGIF($srcFile);
break;
case 2:
$im=@ImageCreateFromJPEG($srcFile);
break;
case 3:
$im=@ImageCreateFromPNG($srcFile);
break;
}
$srcW=ImageSX($im);
$srcH=ImageSY($im);
//----new test begin----
if(function_exists("imagecopyresampled"))
{
$ni = imagecreatetruecolor($dstW, $dstH);
imagecopyresampled($ni, $im, 0, 0, 0, 0, $dstW, $dstH, $srcW, $srcH);
}else{
$ni = imagecreate($dstW, $dstH);
imagecopyresized($ni, $im, 0, 0, 0, 0, $dstW, $dstH, $srcW, $srcH);
}
ImageJpeg ($ni,$dstFile);
//----new test end----
/*
$ni=ImageCreate($dstW,$dstH);
ImageCopyResized($ni,$im,0,0,0,0,$dstW,$dstH,$srcW,$srcH);
ImageJpeg($ni,$dstFile);
*/
// ҪรดһΪImageJpeg($ni);
// ҪʽͼƬĶһͿ
}
makethumb2($ECardRoot_W."/".$newfntb,$ECardRoot_W."/".$newfn,$width,$height);
return $newfn;
}I think it may be the php.ini or with the uploadimg folder permission but I have no idea what to touch.
Any idea would be welcomed!
Thank you!
Luca
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]