[英]Is my code below secure enough to be used in production?
根据以下代码,将图片安全地上传到php脚本的最佳做法是什么? 我正在使用文件传输cordova插件将图像上传到php脚本。
Javascript(文件传输cordova插件)
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
options.mimeType = "image/jpeg";
var params = new Object();
params.imageLink = "test";
options.params = params;
options.chunkedMode = false;
var ft = new FileTransfer();
ft.upload(imageURI, "http://example.com/upload.php", win, fail, options);
alert("Post Uploading");
function win(r) {
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
alert(r.response);
}
function fail(error) {
$.mobile.loading('hide');
navigator.notification.alert("An error has occurred: Code = " + error.code, null, 'Alert', 'OK');
}
的PHP
<?php
if(isset($_POST['imageLink'])) {
$imageLink = $_POST['imageLink'];
print_r($_FILES);
$new_image_name = $imageLink.".jpg";
move_uploaded_file($_FILES["file"]["tmp_name"], “uploads/“.$new_image_name);
}
?>
有什么建议么?
取决于要保护的内容:
上面的列表只是一个开始。 安全是一个比我们期望的要深得多的兔子漏洞。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.