I have a problem. This is my code:
<?
//Get FTP Pass, User, Server, and Category
$ftp = "SELECT ftp_server, ftp_user, ftp_pass, ftp_cat, address FROM
layout_servers where ftp_cat = '$_SESSION[cat_id]'";
$ftp_res = mysql_query($ftp) or die (mysql_error());
while ($row5 = mysql_fetch_assoc($ftp_res))
{
$ftp_server = $row5['ftp_server'];
$address = $row5['address'];
$ftp_user = $row5['ftp_user'];
$ftp_pass = $row5['ftp_pass'];
$ftp_cat = $row5['ftp_cat'];
}
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!<br>";
echo "Attempted to connect to $ftp_server for user $ftp_user";
exit();
} else {
ftp_chdir ($conn_id, $_GET[type]);
ftp_mkdir ($conn_id, $_GET[dirname]);
$dir = "temp/$_GET[dirname]/";
$files = array();
$open = opendir($dir);
while ($file = readdir($open)) { if ($file != "." && $file != "..") { $files[] =
$file; } }
closedir($open);
sort($files);
reset($files);
for ( $i=0; $i < count($files); $i++ ) {
//Upload
$source_file="temp/$_GET[dirname]/$files[$i]";
$destination_file="$_GET[dirname]/$files[$i]";
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
unlink($source_file);
}
if($upload) {
rmdir("temp/$_GET[dirname]");
echo "Files moved to $ftp_server";
echo "<img src=$address/$_GET[dirname]/$zip>";
} else {
echo "Error uploading. Contact the webmistress immediately.";
}
}
// close the FTP stream
ftp_close($conn_id);
//++++++++++++++++++++++++++++++++++++++
}
?>
However, once I upload the two images in the array- when I try to display them with this PHP script:
<?
$thumb = "$server/$cat/$item_id/$item_image";
?>
It says that it's broken. And if I go to the file address itself, it says that the image cannot be accessed. However, if I refresh, it works and works for the rest of the time.
Can you help me?