Aer*_*iel 0 php ftp performance multithreading
我已经制作了一个正在等待文件的表格。提交后,文件将通过该ftp_put()功能上传到远程服务器。问题是它需要大约 2/3 分钟。
我尝试一一删除行以找出问题所在,但对它的调用ftp_put()花费了很多时间。文件只有20Ko。有没有办法在其他线程或其他线程中上传文件?
编辑:这是我的 php 代码。
$file = $_FILES['attachment']['tmp_name'];
$ext = pathinfo($_FILES['attachment']['name'], PATHINFO_EXTENSION);
$remote_file = '/cv_'.$_POST['first_name'].'_'.$_POST['last_name'].'_'.strval(time()).'.'.$ext;
$ftp_server = 'xxxxxxxxx';
$ftp_user_name = 'xxxxxx';
$ftp_user_pass = 'xxxxxx';
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if (!ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) /* This line is taking so long */
{
echo "There was a problem uploading the file $file\n";
}
ftp_close($conn_id);
Run Code Online (Sandbox Code Playgroud)
编辑 2:文件在几分钟后正确上传。该代码在本地主机上运行良好且快速,但是当它在生产服务器上时,它开始花费很长时间。