PHP和FTP的大文件上传问题


Large file upload issue with PHP and FTP

我正在设计的网站的一个组件出现问题。我在通过页面上传文件时遇到问题。。。PHP的上限为32mb。我正在处理的文件系统,我希望文件大小在500mb左右。大多数在250-300左右…但想要缓冲。我听说过通过直接ftp上传。我相信这就是我需要走的方向:

   <?php
// connect and login to FTP server
$ftp_server = "ftp.example.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
$file = "localfile.txt";
// upload file
if (ftp_put($ftp_conn, "serverfile.txt", $file, FTP_ASCII))
  {
  echo "Successfully uploaded $file.";
  }
else
  {
  echo "Error uploading $file.";
  }
// close connection
ftp_close($ftp_conn);
?>

这将是我的html和php。

<?php
include_once(db_conx.php);
?><?php
error_reporting(E_ALL);
if(isset($_POST['submit'])){

    $name = $_FILES['file']['name'];
    $temp = $_FILES['file']['tmp_name'];
    move_uploaded_file($temp,"vids/".$file);
    $url = "http://x-webb.com/vids/.$file";
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>video uploader</title>
<meta name="" content="">
</head>
<body>
    <h1>Video Uploader</h1>
<form  method="POST" enctype="multipart/form-data">
    Video: <br>
    <input type="file" name="name"><br />
    <label for="title">Title:</label><br>
    <input type="text" name="title" id="title" placeholder="required" ><br>
    <label for="description">Description:</label><br>
    <textarea name="description" id="description" placeholder="required" ></textarea><br>
    <label for="tags">Tags:</label><br>
    <textarea name="tags" id="tags" placeholder="required" ></textarea><br>
<input type="submit" value="upload">
</form>
</body>
</html>

我好像就是不能把这两个放在一起。我有ftp服务器的ftp_conx.php文件。。签出正常…没有错误。我已经为一个爱好用html和CSS编程了大约18个月。。。使用ajax和php大约2个月。我构建的页面是autodude666.com/networkx-webb.com我希望放置此代码的当前项目是:http://x-webb.com

如有任何帮助,我们将不胜感激。提前TY。

您可以在PHP中增加最大上传大小。在php.ini中进行调整:

upload_max_filesize = 500M
post_max_size = 500M

此外,您应该考虑用户上传500MB文件所需的时间,并相应地设置最长时间限制。

我从您提供的站点的服务器签名头中看到您使用的是Apache,但对于其他可能运行nginx+php-fpm的人,您还必须增加nginx-config的http块中的client_max_body_size的值,否则您将看到413个错误。