我想知道通过ftp_put()函数将其他文件上传到服务器后是否可以保留原始文件名,因为到目前为止,该文件每次都会被下一个要上传的文件覆盖,因为总是同一个名字。
这是html格式:
<form action='../upload.php' enctype='multipart/form-data' method='post'>
<input name='file' type='file'/>
<input name='submit' type='submit' value='Upload'/>
</form>
这是php代码:
$target_dir = "images/gallery-images/";
$ftp_server = "localhost";
$ftp_user = "abc";
$ftp_pass = "abc";
$file = $_FILES["file"]["tmp_name"];
$remote_file = "abc.jpg";
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
if (ftp_put($conn_id, $remote_file, $file, FTP_BINARY)) {
echo "Successfully uploaded $file\n";
exit;
}
else {
echo "There was a problem while uploading $file\n";
exit;
}
ftp_close($conn_id);
?>
ftp_put()有什么替代方法吗?
非常感谢