2014-10-11 65 views
0

我遇到了一个我正在设计的网站组件的问题。我无法通过页面上传文件... PHP的上限为32mb。我正在处理的文件系统,我预计在500MB附近的文件。大多数在250-300左右......但想要这个缓冲区。我听说过直接通过ftp上传。我相信这是我需要走的方向:PHP和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> 

我只是不能把2放在一起。我有为ftp服务器的ftp_conx.php文件的..选中了好的...没有错误。 我一直在用HTML和CSS编写约18个月的业余爱好...约2个月与AJAX和PHP。我内置的网页是 autodude666.com/network x-webb.com 当前的项目,在这里我希望把这个代码是: http://x-webb.com

任何帮助,将不胜感激。 TY提前。

回答

0

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

upload_max_filesize = 500M 
post_max_size = 500M 

此外,你应该考虑的时候它需要用户上传500MB的文件,并设置相应的最大时间限制量。

我看到您从您提供的站点的服务器签名标头使用Apache,但对于可能正在运行nginx + php-fpm的任何其他人,您还必须增加http块中的值client_max_body_size你的nginx配置,否则你会看到413错误。