Code:
$upfile = ' uploads/'. Rand (0,10000). Date (' Ymdhis '). Iconv ("gb2312", "UTF-8", $_files[' upload ' [' name ']); $upfile is the link address of the uploaded image, stored in the database
The name of the original picture in the link address displayed in the database cannot be displayed, and the image suffix format cannot be displayed.
For example, the database shows the link is: Uploads/34420121102122153android Liao
and the original upload image is: Android development framework. jpg
Reply content:
Code:
$upfile = ' uploads/'. Rand (0,10000). Date (' Ymdhis '). Iconv ("gb2312", "UTF-8", $_files[' upload ' [' name ']); $upfile is the link address of the uploaded image, stored in the database
The name of the original picture in the link address displayed in the database cannot be displayed, and the image suffix format cannot be displayed.
For example, the database shows the link is: Uploads/34420121102122153android Liao
and the original upload image is: Android development framework. jpg
First of all, it must be the coding problem.
You have three places involved in coding problems, there is a conversion between, very likely to be confused, I suggest you all unified UTF8 code
- The file name of the upload
$_FILES['upload']['name'] . Look at your code, turn this from gb2312 to UTF8, but first to determine if your original file name upload is really gb2312, need to convert, if you do not need to convert.
- What is your database format when you deposit it into the database?
- What is the format of the display when the database is read out?
Suggest you check these three places, separately print out to see, unified code, can solve the problem
Linux the following files, try not to name in Chinese
Direct
$upfile = ' uploads/'. Rand (0,10000). Date (' Ymdhis ');
What's the use of your file name?
Generally, the way to do this is: rename after uploading, in the server to store the corresponding table in the manner of pairing. Various operating systems store file encoding is different, and program code is a variety of coding, unified Rename storage is the best way.
is the HTML page of your upload form encoding a utf-8? What do you have to do to transcode it once?