请,我真的需要你的帮助。 我在使用PHP表单将文件上传到FTP服务器时遇到问题。 这种形式还可以,但是我的托管服务提供商最近更改了PHP版本,从那时起,我遇到了很多问题。 与数据库的通信正常,但文件传输不正常。 请,有人可以建议我吗? 非常感谢您的帮助!
表格:
<? include('./config.php'); ?>
<?
$spojeni = @MySQL_Connect($se, $uz, $he);
$db = @MySQL_Select_DB($DB);
?>
<FORM METHOD="POST" action="ins_info.php" enctype="multipart/form-data">
<TABLE>
<TR><TD><u><b>Upload a file:</b></u></TD></TR>
<TR>
<TD><b>Title:</b></TD>
<TD><INPUT TYPE="TEXT" NAME="titulek_form"></INPUT></TD>
</TR>
<TR>
<TD><b>Date:</b></TD>
<TD><INPUT TYPE="TEXT" NAME="datum_form"></INPUT></TD>
</TR>
<TR>
<TD><b>File:</b></TD>
<TD><INPUT TYPE="FILE" ACCEPT="*/*" SIZE="33" NAME="soubor"></INPUT></TD>
</TR>
<TR>
<TD><INPUT TYPE="SUBMIT" NAME="Odeslat" VALUE="Add to database"></INPUT></TD>
</TR>
</TABLE>
</FORM>
和文件ins_info.php :(来自表单的文件获得了新名称,例如info1234.pdf,但是现在只写数据库工作了,结果是我得到了info1234。(FTP上没有文件并且在数据库中没有文件类型)
<? include('./config.php') ?>
<?
@Set_Time_Limit(0);
$INI_ADMIN_PASSWORD = $_GET[INI_ADMIN_PASSWORD];
$INI_ftp_server = $_GET[INI_ftp_server];
$INI_info_path = $_GET[INI_info_path];
$INI_server_info_path = $_GET[INI_server_info_path];
$INI_server_tmp_path = $_GET[INI_server_tmp_path];
$INI_ftp_user = $_GET[INI_ftp_user];
$INI_ftp_pass = $_GET[INI_ftp_pass];
$spojeni_ftp = $_GET[spojeni_ftp];
$soubor = $_FILES["soubor"]["name"];
$titulek_form = $_POST["titulek_form"];
$datum_form = $_POST["datum_form"];
$DatumInt = $_POST["DatumInt"];
$MaxID = $_POST["MaxID"];
$prenos_info = $_POST["prenos_info"];
$vloz_info = $_POST["vloz_info"];
$jmeno = $_POST["jmeno"];
$vyber2 = $_POST["vyber2"];
$datum2 = $_POST["datum2"];
$nazev = $_POST["nazev"];
$soubor_name = $_POST["soubor_name"];
$cislo = $_POST["cislo"];
$jmeno = $_POST["jmeno"];*
IF($PASSWORD==$INI_ADMIN_PASSWORD):
$spojeni = @MySQL_Connect($se, $uz, $he);
$db = @MySQL_Select_DB($DB);
$vyber2 = @MySQL_Query("SELECT Max(ID) FROM info");
$MaxID = @MySQL_Result($vyber2, 0) +1;
$titulek_form = HTMLSpecialChars($titulek_form);
$datum_form = HTMLSpecialChars($datum_form);
$datum2 = Explode(".", $datum_form);
$DatumInt = MkTime(0,0,0, $datum2[1], $datum2[0], $datum2[2]);
$jmeno = "info";
$i = 1;
do
{
if($i==1) $jmeno_old = $jmeno;
$jmeno = $jmeno_old;
$nazev = Explode(".", $soubor_name);
SRand((double)MicroTime()*1e6);
$cislo = Rand (1, 9999);
// $nazev[0] .= $cislo;
$jmeno .= $cislo.".".$nazev[1];
$i++;
}
While(@File_Exists("$INI_info_path$jmeno"));
$vloz_info = @MySQL_Query("INSERT INTO info VALUES ('$MaxID', '$titulek_form', '$datum_form', '$jmeno', '$DatumInt')");
// *** FTP start
@chdir("$INI_server_tmp_path"); // docasny adresar
$spojeni_ftp = @ftp_connect("$INI_ftp_server"); // pripojeni k FTP serveru
@ftp_login($spojeni_ftp, "$INI_ftp_user", "$INI_ftp_pass"); // prihlaseni k FTP serveru
$prenos_info = @ftp_put($spojeni_ftp, "$INI_info_ftp_path$jmeno", "$soubor", FTP_BINARY); // kam se ma soubor ulozit
@chdir("$INI_server_home_path"); // nastaveni domovskeho adresare
@ftp_close($spojeni_ftp); // odhlaseni od FTP serveru
// *** FTP end
Header("Location: status.php?prenos_info=$prenos_info&vloz_info=$vloz_info");
?>
<?
ELSE:
Echo "<p>Error</b></p>";
ENDIF;
?>
文件夹具有777权限 。 我对文件开头的POST和GET方法感到怀疑。