这是我上传的代码。它在我的浏览器中工作,但不能在其他系统的其他浏览器中工作,IE:|此代码必须访问用户才能上传zip文件,
function GetRandomName(){
settype($randtxt, "string");
$temp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for($i=0; $i<15; $i++){
$tekrar = rand(0,strlen($temp)-1);
$randtxt .= $temp[$tekrar];
}
return $randtxt;
}// end of func GetRandomName
function GetTypef($name){
$back = strpos($name,".");
$front = strlen($name) - $back;
$type = substr($name,$back,$front);
return $type;
}
if (isset($_POST['days'])){
$ex = explode(".", $_FILES["file"]["name"]);
$ex_format = end($ex);
if (($_FILES["user-file"]["type"] == "application/zip")
or($_FILES["user-file"]["type"] == "application/x-zip-compressed")
or($_FILES["user-file"]["type"] == "application/x-rar-compressed")
or($_FILES["user-file"]["type"] == "multipart/x-zip")
or($_FILES["user-file"]["type"] == "multipart/x-rar")
&& ($_FILES["user-file"]["size"] < 1000000)) {
if ($_FILES["user-file"]["error"] > 0){
$_SESSION['msg2']="error";
$check_result = 0;
}
else{
if (file_exists("../request-file/" . $_FILES["user-file"]["name"])){
$rand_name = GetRandomName(); // get ranadom name for pictures
$type_file = GetTypef($_FILES["user-file"]["name"]); // get type of file;
$filename = $_FILES["user-file"]["name"] = $rand_name . $type_file;
}
else{
$rand_name = GetRandomName(); // get ranadom name for pictures
$type_file = GetTypef($_FILES["user-file"]["name"]); // get type of file;
$filename = $_FILES["user-file"]["name"] = $rand_name . $type_file; //change file names
move_uploaded_file($_FILES["user-file"]["tmp_name"],"../request-file/" . $_FILES["user-file"]["name"]);
$q = sprintf("INSERT INTO requestfile ( `uid`, `tarikhersal`, `hour`, `days`, `name`, `file`, `translate`, `subject`, `translateto`, `translatein`) VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s','%s', '%s');",$_SESSION["us"],$jalali_date,$jalali_hour,$_POST["days"],$filename,$_FILES["user-file"],$_POST["translate"],$_POST["subject"],$_POST["translateto"],$_POST["translatein"]);
mysql_query($q);
$_SESSION['msg']="OK ";
header("location:follow.php");
}}}
else{
if($_FILES["user-file"]["size"] > 1000000){
$_SESSION['msg2']="big size";
}else {
$_SESSION['msg2']="again upload";
}
}}
问题是什么?以及如何解决它?请帮忙,我很头晕......
答案 0 :(得分:1)
也许您的浏览器具有扩展名,可以帮助您上传此文件。
请检查其他文件并进行测试。如果您在文件编辑index.php文件中遇到显示错误的问题。
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');