search
HomeBackend DevelopmentPHP Tutoriallinux中文文件名不能访问,求教,在线等。

以前windows的服务器被别人直接丢了很多中文文件名的图片,现在换到linux上面了,中文的图片就不能访问了,如http://www.gopalau.net/files/PPR/%E5%9B%BD%E7%8E%8B%E4%B8%8E%E7%8E%8B%E5%90%8E%E9%A4%90%E5%8E%85.jpg
网上找了很多,都说需要mod_encoding,但是按照相关方法还是不行,有些rpm也装不上,或是没有资源了。
我的服务器类型是:Apache/2.4.6 (CentOS) PHP/5.4.16
请问有没有什么方法能解决,谢谢了。
@xuzuning 


回复讨论(解决方案)

%E5%9B%BD%E7%8E%8B%E4%B8%8E%E7%8E%8B%E5%90%8E%E9%A4%90%E5%8E%85.jpg
是 utf-8 的 国王与王后餐厅.jpg 的 url 编码

你在迁移服务器时注意到中文文件名的字符集了吗?
也就是说你的新服务器上的对应目录里有 国王与王后餐厅.jpg 这个文件吗?


从截图上开,你的 web 服务器是不支持中文 url 的(Apache 默认就是不支持中文 url 的)

%E5%9B%BD%E7%8E%8B%E4%B8%8E%E7%8E%8B%E5%90%8E%E9%A4%90%E5%8E%85.jpg
是 utf-8 的 国王与王后餐厅.jpg 的 url 编码

你在迁移服务器时注意到中文文件名的字符集了吗?
也就是说你的新服务器上的对应目录里有 国王与王后餐厅.jpg 这个文件吗?


从截图上开,你的 web 服务器是不支持中文 url 的(Apache 默认就是不支持中文 url 的)


有的,而且用迅雷下载也可以下载下来。

我的程序是 gbk 编码的

也就是说你在服务器上的中文文件名也是 gbk 编码的

你并没有如实反映情况!

你要按 gbk 中文做 url 编码
http://www.gopalau.net/files/PPR/%B9%FA%CD%F5%D3%EB%CD%F5%BA%F3%B2%CD%CC%FC.jpg

我的程序是 gbk 编码的

也就是说你在服务器上的中文文件名也是 gbk 编码的

你并没有如实反映情况!


之前因为直接从window打包压缩放到linux上面的,解压出来是乱码如:PPR-+-+-恽芯?++ャ鳞?使.jpg,所以我就直接再放了一个“国王与王后餐厅.jpg”上去,你说的是没有如实反映情况是什么呢?能告诉你需要我提供哪些信息呢?

你要按 gbk 中文做 url 编码
http://www.gopalau.net/files/PPR/%B9%FA%CD%F5%D3%EB%CD%F5%BA%F3%B2%CD%CC%FC.jpg


我也想过将url编码转换一下,但是图片全部是在文章里面隔三岔五的linux中文文件名不能访问,求教,在线等。显示一下

能不能给我一个正则表达式,将内容里面的linux中文文件名不能访问,求教,在线等。 urlencode(iconv("utf-8","gbk","祖宁.jpg")),谢谢老大。

我说你 没有如实反映情况,是因为:
你的中文文件名实际是 gbk 的,而你却说已经转成 utf-8 的了

你用 utf-8 的中文文件名,去访问 gbk 的中文文件,当然是找不到的

XZN


有没有办法修改liunx配置
服务器类型是:Apache/2.4.6 (CentOS) PHP/5.4.16
让直接可以以下面这个网址访问
http://www.gopalau.net/files/palasia-hotel-palau/帛琉大饭店游泳池.jpg  (linux现在不能访问)
以前的
http://www.citssz.net/files/palasia-hotel-palau/帛琉大饭店游泳池.jpg(之前的windows可以访问)

为了跨平台还是建议不要用中文命名

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Working with Flash Session Data in LaravelWorking with Flash Session Data in LaravelMar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

cURL in PHP: How to Use the PHP cURL Extension in REST APIscURL in PHP: How to Use the PHP cURL Extension in REST APIsMar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Simplified HTTP Response Mocking in Laravel TestsSimplified HTTP Response Mocking in Laravel TestsMar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

12 Best PHP Chat Scripts on CodeCanyon12 Best PHP Chat Scripts on CodeCanyonMar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Explain the concept of late static binding in PHP.Explain the concept of late static binding in PHP.Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

PHP Logging: Best Practices for PHP Log AnalysisPHP Logging: Best Practices for PHP Log AnalysisMar 10, 2025 pm 02:32 PM

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

HTTP Method Verification in LaravelHTTP Method Verification in LaravelMar 05, 2025 pm 04:14 PM

Laravel simplifies HTTP verb handling in incoming requests, streamlining diverse operation management within your applications. The method() and isMethod() methods efficiently identify and validate request types. This feature is crucial for building

Discover File Downloads in Laravel with Storage::downloadDiscover File Downloads in Laravel with Storage::downloadMar 06, 2025 am 02:22 AM

The Storage::download method of the Laravel framework provides a concise API for safely handling file downloads while managing abstractions of file storage. Here is an example of using Storage::download() in the example controller:

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.