Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7755857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:40:10+00:00 2026-06-01T12:40:10+00:00

I cannot pass a UTF-8 filename to move_uploaded_file() as it gets converted bytewise, resulting

  • 0

I cannot pass a UTF-8 filename to move_uploaded_file() as it gets converted bytewise, resulting in a faulty name in the file system. For example:

move_uploaded_file($_FILES['userfile']['tmp_name'], '\upload\é.jpg');

creates xa9.jpg in the upload directory.

While the Windows API supports UTF-16, passing such filename (e.g., iconv('UTF-8', 'UTF-16', 'é')) to move_uploaded_file() results in an error.

It would be reasonable to percent-encode all special characters, and I definitely should do the same with the URIs, according to RFC 3986. But when I use percent-encoded URIs, Apache gives a 404 error, as it decodes the URL and can’t find anything by that name.

For example: <img src="/upload/%C3%A9.jpg" /> gives the Apache error:

File does not exist: […]/upload/\xc3\xa9.jpg.

What would be the proper solution? If I rename the file in Windows (é.jpg), the encoded HTML URI (%C3%A9.jpg) works as expected.


Some info on the subject: http://www.rooftopsolutions.nl/blog/filesystem-encoding-and-php

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:40:12+00:00Added an answer on June 1, 2026 at 12:40 pm

    Passing iconv('UTF-8', 'Windows-1250', $_FILES['userfile']['name']) to move_uploaded_file(), as opposed to using UTF-16, and saving the filename for HTML as rawurlencode($_FILES['userfile']['name']) works.

    If this filename is stored in a database, any file request should refer to iconv('UTF-8', 'Windows-1250', rawurldecode($filename)).

    I use Windows-1250 charater set as this is the default on my system.

    Additional info on MSDN:

    • Character Sets Used in File Names (See: Code Pages)

    • File and Directory Names (Naming Conventions)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this warning from GCC: warning: cannot pass objects of non-POD type 'class
I cannot get request specs working when using Javascript. My specs pass if I
I cannot get my SID working ... <?php session_start(); // Or maybe pass along
I am trying to pass a value from C++ to TCL. As I cannot
How can I get this test to pass without resorting to runs/waitsFor blocks? it(cannot
I have this little problem, that I cannot figure out which arguments to pass
Cannot dump Stack Overflow XML file into SQL Server 2008. Could you please explain
Cannot find any example on Google.
I've been struggling to make it work, but cannot pass the inserted data from
In my legacy website, I found this <input type=image id=QuickPass name=QuickPass src=/images/QuickPass.gif alt=Quick Pass

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.