Hey all,
I'm stuck with compressing an image then uploading it to my server here is my current code and I would like to implement it in that. Any ideas or help would be appreciated. I have look at the GD functions and am confused!! I need a hand to hold!!
Jack 😃
<?php
session_start();
if ($photo1 != "none" or $photo2 != "none" or $photo3 != "none" or $photo4 != "none" or $photo5 != "none" or $photo6 != "none")
{
$i=0;
$numphotos=0;
$imageno=1;
$array=array();
while ($i<6)
{
$i++;
$photo=photo;
$photo.=$i;
if ( is_uploaded_file ( $HTTP_POST_FILES[$photo]['tmp_name']) ) {
$imagetype=$HTTP_POST_FILES[$photo]['type'];
if($imagetype=='image/pjpeg' || $imagetype=='image/gif') {}
else { $error.="One or more of your image types were unsupported"; }
$array[$imageno] = $$photo;
$imageno++;
$numphotos++;
}
}
}
else {$empty="Y";}
Next part of script:
if ($numphotos!=0) {
$info=mysql_query("select * from classifieds where title='$title' and price='$price' and description='$description'");
while ($row=mysql_fetch_array($info))
{
$classid=$row[id];
}
$i=0;
$imagepath="/home/guitar/public_html/ftpupload/$classid/";
while ($i<=$numphotos)
{
if ($i==0 ) { mkdir("$imagepath", 0777 ); }
move_uploaded_file( $array[$i] , "/home/guitar/public_html/ftpupload/$classid/$i.jpg");
$i++;
}
$photo="insert into classphotos (id, numphotos";
$i=1;
while ($i<=$numphotos)
{
$photo .= ",photo";
$photo .= $i;
$i++;
}
$photo .= ") values ('";
$photo .= $classid;
$photo .="','";
$photo .= $numphotos;
$photo .="'";
$i=1;
while ($i<=$numphotos)
{
$photo .= ",'";
$photo .= "http://www.jamitch.demon.co.uk/".$classid."/";
$photo .= $i;
$photo .= ".jpg";
$photo .= "'";
$ftp_server = "homepages.demon.co.uk";
$ftp_user_name = "xxx";
$ftp_user_pass = "xxx";
// 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);
// Turn passive mode on
ftp_pasv($conn_id, true);
//Make new directory
if ($i==1) { ftp_mkdir($conn_id,$classid); }
//Change directory
ftp_chdir($conn_id, "$classid");
// upload the file
$upload = ftp_put($conn_id, "$i.jpg","/home/guitar/public_html/ftpupload/$classid/$i.jpg", FTP_ASCII);
$i++;
}
$photo .= ")";
mysql_query("$photo") or die (mysql_error() );
// close the FTP stream
ftp_close($conn_id);
}
}
else { print "<script> location.href='listguitar.php?error=$error' </script>"; die($error); }
?>