|
Posted by NurAzije on 12/29/05 15:26
Thank you very much, I've done it, this is the script:
<?php
$ftp_server="Server";
$ftp_user_name="UserName";
$ftp_user_pass="Password";
$path="Directory_Path_of _Images";
$pathwww="FTP_Directory_Path_of_images";
$mode1="0777";
$mode2="0644";
$quality=70;
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
//list the directory of images
$d = dir($path);
while(false !== ($e = $d->read())){
if(strpos($e,'.jpg')){
// try to chmod $file to 777
$file=$e;
$command1="CHMOD $mode1 $pathwww/$file";
$command2="CHMOD $mode2 $pathwww/$file";
@ftp_site($conn_id, $command1);
$r = imagecreatefromjpeg($path."/".$e);
imagejpeg($r,str_replace('.jpg','.jpg',$e),$quality);
@ftp_site($conn_id, $command2);
echo "Done $e<br>";
}
if(strpos($e,'.gif')){
// try to chmod $file to 777
$file=$e;
$command1="CHMOD $mode1 $pathwww/$file";
$command2="CHMOD $mode2 $pathwww/$file";
@ftp_site($conn_id, $command1);
$r = imagecreatefromgif($path."/".$e);
imagegif($r,str_replace('.gif','.gif',$e),$quality);
@ftp_site($conn_id, $command2);
echo "Done $e<br>";
}
if(strpos($e,'.png')){
// try to chmod $file to 777
$file=$e;
$command1="CHMOD $mode1 $pathwww/$file";
$command2="CHMOD $mode2 $pathwww/$file";
@ftp_site($conn_id, $command1);
$r = imagecreatefrompng($path."/".$e);
imagepng($r,str_replace('.png','.png',$e),$quality);
@ftp_site($conn_id, $command2);
echo "Done $e<br>";
}
}
// close the connection
ftp_close($conn_id);
?>
[Back to original message]
|