【发布时间】:2010-01-16 12:37:11
【问题描述】:
我有一个问题
当我们给 web 用户选择将数据导入 mysql 表时,这是否安全?
例如
<form method="post" action="import.php" enctype="multipart/form-data">
<input id="file1" name="file1" type="file">
<input type="submit" name="button" id="button" value="Submit" >
</form>
在 import.php 中我们有以下代码
<?php
$theFile = $_FILES['file1'];
$tmp_name1 = $theFile['tmp_name'];
$row = 1;
if (($handle = fopen($tmp_name1, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
// SQL insert statement
}
fclose($handle);
}
我的问题是,如果有人上传任何脚本或 .exe 或病毒,这将进入网络服务器临时目录,我们如何保护它?
什么是安全的方式?
谢谢
【问题讨论】:
标签: php security file-upload