我正在尝试使用 php 中的文件上传器控件上传 CSV 文件,如果文件大小超过 10 MB,它不会被上传,它只会挂起页面执行。我已经设定
ini_set("upload_max_filesize", "50M"); ini_set("post_max_size", "50M");
在页面上,我仍然没有运气。如果我上传的文件最大为 8 MB,它的工作正常。我对为什么问题仍然存在感到困惑,我在同一页面上做了与文件大小上传相关的设置。请帮我。
提前致谢,
以下是我的 PHP 代码
<?php
set_time_limit(0); ini_set('display_errors', 1); ini_set( "upload_max_filesize", "100M" ); ini_set( "post_max_size", "100M" );
ini_set( "session.save_handler", "files" ); session_start(); header ('Last-Modified: '.gmdate("D, d M Y H:i ").' GMT'); header ('Expires: '.gmdate("D, d M Y H:i ").' GMT'); header ('Cache-Control: no-cache, must-revalidate'); header ('Pragma: no-cache');
if ($_FILES['import']['error'] == UPLOAD_ERR_OK ) {
$tmpName = $_FILES['import']['tmp_name'];
$csvName = $_FILES['import']['name'];
$mime = $_FILES['import']['type'];
$validMimes = array('text/csv');
if(!strpos($csvName, '.csv'))
{
$errMsg = ' [' . $csvName . '] is INVALID csv file (<i>csv only</i>)';
}
if ( is_uploaded_file($tmpName) && !isset($errMsg) ) // upload photo file then save author if uploaded file is VALID
{
// upload photo to server
$filename = 'uploads/products/';
$pathParts = pathinfo($csvName);
$photoFile = _generateUniquePhoto($pathParts['extension']);
//move_uploaded_file($tmpName, $filename . $photoFile);
//chmod($filename . $photoFile, 0777);
// save to database
$fullfilename = $filename.$photoFile;
//$this->data['University']['add_logo'] = $photoFile;
$ftp_server = "XXXXX";
$ftp_user_name = "XXXX";
$ftp_user_pass = "XXXXX";
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection
if ((!$conn_id) || (!$login_result))
{
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
exit;
} else
{
//echo "Connected to $ftp_server, for user $ftp_user_name";
}
// upload the file
$destination_file1 = "httpdocs/volhub/client/$fullfilename";
$sourcefile1 = "$tmpName";
$upload = ftp_put($conn_id, $destination_file1, $sourcefile1, FTP_BINARY); // line 30
// check upload status
ftp_close($conn_id); }