Tema: Save Image
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/06/2008, 15:50
JBFS
 
Fecha de Ingreso: mayo-2006
Ubicación: Albufeira-Portugal
Mensajes: 19
Antigüedad: 18 años, 10 meses
Puntos: 0
Save Image

Hi
I have a php file called saveimage.php that saves my images in a folder called images on the root of a X website:
$disk_root="..../local/home/x/x.com//";I would like to use the same saveimage.php file to save at the same time the same image on the root of a Y website:
$disk_root="..../local/home/x/y.com//";
Here it is the contents of the saveimage.php file:
Código PHP:
<?
functionmysql_ligar
($mysql_host,$mysql_user,$mysql_pass)
{
if((
$mysql=mysql_connect $mysql_host,$mysql_user,$mysql_pass))==0)return0;
else return
$mysql;}functionmysql_base ($mysql,$mysql_base){if(($out=mysql_select_db($mysql_base,$mysql))==0)return0; else return1;}
include(
"call.inc.php"); $mysql=$connectmysql_base($mysql,"x");
$disk_root="/.../local/home/x/x.com//";
if((!isset(
$client))||(!isset($img)))die("Without client or image"); $name=sprintf("%simage/file%06d%06d.bin",$disk_root,$client,$img);
if((
$fich=@fopen($userfile,"rb")) !=FALSE){
$type=$userfile_type$type1=strtoupper($type);
if((
$type1 !="IMAGE/GIF")&&($type1 !="IMAGE/JPG")&&($type1 !="IMAGE/JPEG")&&($type1 !="IMAGE/PJPEG"))
{ die(
"Not supported image.<BR>The format of images must be GIF or JPG.".$type1); } fseek($fich,0,2);
$size=ftell($fich); if($size>90*1024){
die(
"Image too large. The maximun size is".90*1024); } fseek($fich,0,0); $image=fread($fich,$tam); fclose($fich);
if((
$fich=@fopen($nom,"wb"))==FALSE)die("Error trying to write the image: ".$name);
fwrite($fich,$image); fclose($fich);
$query=sprintf("DELETE FROM images WHERE id=%d AND num=%d",$cliente,$img); if(@mysql_query($query,$mysql)==FALSE)die("Bad query: $query");
$query=sprintf("INSERT INTO images (id, num, type) VALUES (%d, %d, \"%s\")",$client,$img,addslashes($type));
if(@
mysql_query($query,$mysql)==FALSE)die("Bad query: $query"); } else {
$query=sprintf("DELETE FROM images WHERE id=%d AND num=%d",$client,$img);
if(@
mysql_query($query,$mysql)==FALSE)die("Bad query: $query"); }
$query=sprintf("SELECT COUNT(*) FROM images WHERE id=%d",$client);
if((
$result=@mysql_query($query,$mysql))==FALSE)die("Bad query: $query");
list(
$count)=mysql_fetch_row($result);
if(
$count !=0)$count=1;
$query=sprintf("UPDATE clients SET image=%d WHERE id=%d",$count,$client);
if(@
mysql_query($query,$mysql)==FALSE)die("Bad query: $query"); if($count==0)@unlink($name);
header("location: building_photos2.php?id=$client&ref=$ref&agt=$agent_id'"); die();
?>
Thanks

Última edición por jam1138; 04/06/2008 a las 18:28 Razón: Coloco etiquetas de coloreado de código