我有以下问题,我正在使用 HTML5 filedrop 上传 33.3MB 文件。首先,我将文件保存到本地存储,然后将其传输到 ftp 服务器。页面在大约 1 分钟后崩溃,(文件保存到本地存储后)。我注意到它会继续上传,每次刷新页面时,我都会看到文件大小增加。最后它在后台上传,但我当然不希望页面崩溃。如果有人知道原因请回复我。我增加了upload_max_filesize、post_max_size,也增加了超时时间。
$userName = "username";
$pass = "pass";
$root = "FolderBBB";
ini_set('default_socket_timeout', '1000');
ini_set('upload_max_filesize', '1024M');
ini_set('post_max_size', '1024M');
ini_set('max_execution_time', '1000');
ini_set('max_input_time', '1000');
ini_set('memory_limit', '1024M');
$conn = ftp_connect("path",2121,1800) or die("Could not connect");
if (ftp_login($conn, $userName, $pass)){
@ftp_pasv($conn,TRUE);
set_time_limit(0);
if ($_FILES && $_FILES["file"] && $_FILES["file"]["tmp_name"]){
$fullPath = $root.$_POST["path"]."/".$_FILES["file"]["name"];
if (ftp_exists($conn, $fullPath)){
echo "{\"check\": false,\"text\":\"File already exists on server.\"}";
}else{
if(move_uploaded_file($_FILES["file"]["tmp_name"], $_FILES["file"]["name"])){
// echo $root.$_POST["path"]."/".$_FILES["file"]["name"];
if(ftp_put($conn, $fullPath, $_FILES["file"]["name"], FTP_BINARY)){
unlink($_FILES["file"]["name"]);
echo "{\"check\":true, \"text\":\"File(s) were uploaded successfully.\"}";
}else{
echo "{\"check\": false, \"text\":\"File ".$_FILES["file"]["name"]." was not uploaded successfully.\"}";
}
}else{
echo "{\"check\": false, \"text\":\"File ".$_FILES["file"]["name"]." was not uploaded successfully.\"}";
}
}
}
}