上传文件名称中文失败,该怎么处理
上传文件名称中文失败
$dir = $_SERVER['DOCUMENT_ROOT']."/uploads/";
//上传的文件重命名
$filename = $_FILES[$myfile]['name'];
//$filename = mb_convert_encoding($_FILES[$myfile]['name'],"UTF-8","GBK");
//$filename = iconv("gb2312","UTF-8",$_FILES[$myfile]['name']);
//echo $filename;die;
//上传文件的函数move_uploaded_file(文件临时的目录,文件加载的目录)
if(move_uploaded_file($_FILES[$myfile]['tmp_name'],$dir.$filename)){
//解压上传文件
dp_unzipfile($filename,$path);
//echo "文件上传成功";
}else{
echo "上传文件失败";
}
------解决方案--------------------
- PHP code
windows下的路径要这样:D:\\WebService\\doc.juren9.com\\uploads\\房间阿斯顿.zipLinux:# /WebService/doc.juren9.com/uploads/房间阿斯顿.zip.gz<br><font color="#e78608">------解决方案--------------------</font><br>
------解决方案--------------------
中文可以的,把$_FILES[$myfile]打印出来看看
------解决方案--------------------
这是我正在做的项目里的上传图片的文件,伱拿去用吧!!
- PHP code
/*** 功能:* 上传图片* 参数说明:* $imgpath: FILE变量* 返回值:* 1:$imgpath 上传图片成功后的完整图片路径* 2:false 上传图片失败* 2:false 上传图片失败失败* 版本:* v1.0 07年8月5日作第1次修改,*/ function upload_image($imgpath){ $name=$imgpath["name"]; $tmp_name=$imgpath["tmp_name"]; $type=$imgpath["type"]; $size=$imgpath["size"]; $uploadfile = "../index/upload_image/".$imgpath['name']; //time()."_". 上传的位置 $maxsize=500*1024; //最大允许上许文件大小 if($name==""){ //文件名为空 echo"<script>alert('请先选择要上传的图片文件!'); window.history.back();</script>"; } if($size>$maxsize){ //超过规定大小 echo"<script>alert('上传文件大小不能超过500K! ');window.history.back();</script>"; exit; } if(move_uploaded_file($tmp_name,$uploadfile)) return $uploadfile; else if (copy($tmp_name,$uploadfile)) return $uploadfile; else return false; }//upload_image函数部分 在伱需要上传图片的页面调用这个函数 //如果不是一个页面 别忘记在那个页面包含这个文件 $photo=$_FILES['photo']; upload_image($photo);?><br><font color="#e78608">------解决方案--------------------</font><br>重复名 就行 吧<div class="clear"> </div>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In the Java programming language, it is often necessary to perform operations such as reading, writing, copying, and deleting files. Java provides a set of functions of the Files class to perform file operations. This article will introduce how to use the Files function in Java for file operations. Import the required packages. Before performing file operations, you must first import Java's io package and nio package: importjava.io.File;importjava.io.IOException;import

"Files" itself is not a specific file type, but a general concept.

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

PHP cannot get the name because when the name and id values of the form element are different, the browser cannot recognize it. The solution: 1. Check whether some form elements and frame elements use name; 2. Check only Elements that can be assigned ID but not name; 3. For multi-select box checkbox, you can use "join(',', $__POST['name'])" to form data.

File system operations using the new Files and Path classes in Java 11 Java 11 introduces a number of new classes and features, including improvements to file system operations. The new Files class and Path class provide a more convenient and flexible file operation method, allowing us to process files and directories more easily. Before Java11, we usually used the java.io.File class to operate files and directories. However, the functionality of this class is relatively limited and not flexible enough. Java

What is the use of name in Vue3? 1. Name needs to be defined when making recursive components. 2. The component can be cached with keep-aliveincludeexclude. 3. When Vue reports an error or is debugging, you can see the name of the component. Vue3 defines name1. It is automatically generated as long as the setup syntax sugar mode single file component is turned on in the script. The corresponding name option will be automatically generated based on the file name. For example, Tree.vue, then its name will be automatically generated by Tree. This has a drawback. If you want to modify the name, you need to modify the component name. If there is a place to import the component, you need to modify it together. 2. Open a script to define name

In Java, file operations are a common task of working with data files stored in the file system. To perform these tasks effectively and efficiently, following best practices ensures that your code is readable, maintainable, and robust. This article introduces the top 10 best practices for manipulating files in Java to help developers improve the quality of their code and avoid common mistakes. Use Path and NIO.Path instead of File. //Use the Path class to operate files Pathpath=Paths.get("my-file.txt");Files.readAllBytes(path);//Use the nio.Path class to operate files java.nio.file.Pathpa

不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没问题。
