I am trying to upload CSV file using file uploader control in php, If the file size is more that 10 MB its not getting uploaded its just hangs the page execution. I have set
ini_set( "upload_max_filesize", "50M" ); ini_set( "post_max_size", "50M" );
on the page, still don't have any luck for me.If I upload file up to 8 MB its working fine.I am confused about why the isue is still there event I have did setting related to file size upload on same page. Please help me.
Thanks in advance,
Following is my PHP code
<?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); }
ini_set()- Is it your own server? You may also want to consider one of the JS alternatives below as they're usually a better experience (progress bars, multiple simultaneous files, etc)upload_max_filesize and post_max_size