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

  • SEARCH
  • Home
  • 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 8952411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:52:02+00:00 2026-06-15T13:52:02+00:00

I have a problem with file uploading. I’m using that very method described in

  • 0

I have a problem with file uploading. I’m using that very method described in THIS article. I downloaded the whole script published by the author from HERE.
The application is meant to load files through HTML5 drag&drop and then, through javascript, send them to serverside by ajax request.
Everything works fine but the problem occurs when I want to read a parameter from AJAX request header. Here’s the code of PHP “file reader”:

$fn = (isset($_SERVER['HTTP_X_FILENAME']) ? $_SERVER['HTTP_X_FILENAME'] : false);

if ($fn) {
//above there is the upload of the file with file_put_contents function
//which actually works fine when I replace $fn with my own value and ommit the "if" condition

Earlier, the XMLHttpRequest.setRequestHeader method is launched to set “X_FILENAME” header. Here’s the javascript:

var xhr = new XMLHttpRequest();

// start upload
xhr.open("POST", $id("upload").action, true);
xhr.setRequestHeader("X_FILENAME", file.name);
xhr.send(file);

And here’s the proof (a crop from my Chrome’s “firebug”):

When I var_dump the $fn variable in PHP it returns boolean FALSE. What is wrong?

P.S. I’m using XAMPP v1.8.1 with Apache 2.4.3 and PHP 5.4.7 on Win7 x64. I’m running the site on the latest Chrome. As you can guess the site is running on localhost. I didn’t change anything in php.ini file – everything is set to default.

  • 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-15T13:52:03+00:00Added an answer on June 15, 2026 at 1:52 pm

    Underscores don’t seem to be valid characters for header names. Use Hyphens and it will work beautifully.

    xhr.setRequestHeader("X-FILENAME", file.name);
    

    and no changes are required in your PHP.

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

Sidebar

Related Questions

I have some weird problem while uploading a file with a Cyrillic name using
I become use raw socket and i have this problem: bad file descriptor the
I have problem with this code: file = tempfile.TemporaryFile(mode='wrb') file.write(base64.b64decode(data)) file.flush() os.fsync(file) # file.seek(0)
I have problem with session in cakephp.I have one file chat.php that is in
I am using Cakephp as my framework. I have a problem in uploading my
I have a problem that i've struggled with for a long time. This problem
i have a problem with uploading. if ((($_FILES[file][type] == image/gif) || ($_FILES[file][type] == image/jpeg)
all. I have a problem with uploading of the file in Silverlight application. Here
I have problem uploading with primefaces upload widget. After some investigation I noticed that
I'm using uploadify (a jQuery uploading) script, which has basically a PHP file at

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.