Ver Mensaje Individual
  #8 (permalink)  
Antiguo 08/02/2003, 11:04
rashid
 
Fecha de Ingreso: enero-2002
Ubicación: Perez Zeledon Costa Rica
Mensajes: 1.009
Antigüedad: 22 años, 3 meses
Puntos: 11
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
exit;
}
//directorylike /www.velibaba.com/images
ftp_chdir($conn_id, "www");
ftp_chdir($conn_id, "php");
ftp_chdir($conn_id, "images");
ftp_chdir($conn_id, "clients");
$destination_file=ftp_pwd($conn_id);

$file=getname($path,$browser);
$extencion = substr($file,strlen($file)-3,strlen($file));
$destination_file= date("Ymdhis").".".$extencion;
//echo $destination_file;
//exit;

// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);

// check upload status
if (!$upload) {
echo "FTP upload has failed!";
} else {
//echo $username." -- ". $cid;
updatedbimagename($destination_file, $username, $cid);

echo "
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html>
<head>
<title>Upload Success ".$destination_file."</title>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
</head>
<body background='images/fondoparaflash.jpg'>
<table width='100%' border='0'>
<tr>
<td align='center'>UPLOAD SUCCESS</td>
</tr>
<tr>
<td align='center'><a href='javascript:window.close();'>Click Here to Close</a></td>
</tr>
</table>
</body>
</html>
";
}

// close the FTP stream
ftp_close($conn_id);


function getname($ruta,$browser){
//echo $ruta;
$strKeywordsTokens = explode("\\\\",trim($ruta));
$ult = count($strKeywordsTokens);
$last = $strKeywordsTokens[$ult-1] ;
//echo $browser;
if ($browser =='Netscape Navigator'){
$last= substr($last,0,strlen($last)-2);
}
if ($browser =='Opera'){
$last= substr($last,0,strlen($last)-2);
}

return $last;
}
switch ($f){

case "1":

function updatedbimagename($destination_file, $username, $cid){
@ $db=mysql_connect ("localhost", "h_r", "r");
if (!$db){
echo "Error: Could not connect to database. Please try again later.";
exit;
}
mysql_select_db ("h_d");

($HTTP_POST_VARS['btnSubmit']!="")

$sql="INSERT INTO fotos (id,cid,image1,description1) VALUES ('','$cid','$image1','$description1')";
$result = mysql_query($query);
if ($result){
echo "<script>document.location.href='/php/uploadForm2.php?f=2&cid=".$cid."'</script>";
}else{
echo " <script>document.location.href='/php/error.php?err=0'</script>";
//echo $query;
}

} // insertar
;
break;