我目前有一个上传表单,该表单通过其API将文件发送到Dropbox。执行cURL之后将文件接收到的.php如下:
$localFile = $_FILES["file_key"]['tmp_name'];
$fp = fopen($localFile, 'r');
$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_URL, 'https://content.dropboxapi.com/2/files/upload');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"authorization: Bearer MY-TOKEN",
"content-type: application/octet-stream",
"dropbox-api-arg: {\"path\": \"/tmp/a.txt\",\"mode\": \"add\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}"
));
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 86400); // 1 Day Timeout
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
curl_setopt($ch, CURLOPT_BUFFERSIZE, 128);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localFile));
curl_exec ($ch);
这很完美,但是fopen第二行让我感到困扰。不好的做法是用这个吗?即使是“只读”模式,我也可以接收恶意文件并破坏系统吗?
PIPIONE
狐的传说
交互式爱情