我正在尝试上传pdf文件并稍后查看上传的文件,问题是它是否正确上传但是如果有一些带有unicode字符的文件名,那么它也正在上传,但由于URL问题我无法查看获取404错误unicode文件名在我的服务器中编码错误,这里是代码。
$maxsize = 10485760;
$format = array('application/pdf');
if ($_FILES['file']['size'] >= $maxsize) {
$error_1 = 'File Size too large upload files less than 10MB';
echo '<script>alert("'.$error_1.
'")</script>'; ?
>
<
script >
window.location = "add_files_dev.php"; </script>
<?php
}
elseif($_FILES['file']['size']==0){
$error_2='Invalid File';
echo '<script>alert("'.$error_2.'")</script>';
}
elseif(!in_array($_FILES['file']['type'],$format)){
$error_3='Format Not Supported.Only .PDF files are accepted';
echo '<script>alert("'.$error_3.'")</script>';
?> <
script >
window.location = "add_files_dev.php"; </script> << ?
php
} else {
$file = rand(1000, 100000).
"-".$_FILES['file']['name'];
$file_loc = $_FILES['file']['tmp_name'];
$file_size = $_FILES['file']['size'];
$file_type = $_FILES['file']['type'];
$folder = "uploads/";
// new file size in KB
$new_size = $file_size / 1024;
// new file size in KB
// make file name in lower case
$new_file_name = strtolower($file);
// make file name in lower case
$final_file = str_replace(' ', '-', $new_file_name);
}
move_uploaded_file($file_loc, $folder.$final_file)
答案 0 :(得分:0)
尝试添加AddDefaultCharset
或更改(如果已存在于httpd.conf
AddDefaultCharset utf-8
如果您无法访问它,请创建.htaccess文件并将此代码放入
AddDefaultCharset utf-8