是否可以通过PHP中访问http请求来衡量文件上传进度?如果是这样,我如何在将文件上传到 MySQL 数据库时执行此操作?
require('../connect_db.php');
//Gather all required data
$name = $dbc->real_escape_string($_FILES['uploaded_file']
['name']);
$data = $dbc->real_escape_string(file_get_contents($_FILES['uploaded_file']
['tmp_name']));
$size = intval($_FILES['uploaded_file']['size']);
//create the sql query
$query = "INSERT INTO `".$user."`(
name,size,data,created
)
VALUES (
'$name','$size','$data',NOW()
)";
最佳答案
对于带有客户端进度的文件上传,我建议使用类似的 jQuery 插件 -
http://runnable.com/UZKDAYo3XEw2AACX/how-to-upload-a-file-using-jquery-for-php
而且我不认为将文件存储在数据库中,尤其是 MySQL 中是个好主意。
关于javascript - PHP中通过http请求获取上传进度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23971369/