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 7704095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:36:29+00:00 2026-05-31T23:36:29+00:00

I have this small PHP script that takes a POST variable and writes it

  • 0

I have this small PHP script that takes a POST variable and writes it out to a file.

<?php
   $fileContents = $_POST["Contents"];
   $fileName = $_POST["Name"];
   $filePath = $_POST["Path"];

   $passcode = $_POST["Passcode"];

   if ($passcode != "<passcode>")
      die();

   if (!is_dir("./upload/$filePath"))
      mkdir("./upload/$filePath", 0755, true);

   $file = "./upload/$filePath" . $fileName;

   $fd = fopen($file, "w");
   fwrite($fd, $fileContents);
   fclose($fd);
?>

This seems to work fine for most text given, but in the event where text containing a percent sign (%) is given, the following oddity occurs:

fivice = getField( %bind, 0 );

The original text was:

%device = getField( %bind, 0 );

I send the POST request with the following server request:

POST path/to/Upload.php HTTP/1.1\nHost: host.com\nContent-Type: application/x-www-form-urlencoded\nContent-Length: <length>\n\n<file data>\n

This also occurs with many other cases, but, as you can see, not with %bind.
I looked for the cause of this and found something on %%, so I tried a %%-escaper and got this:

%fivice = getField( %%bind, 0 );

Is there any way to fix this % problem? Also, is the % problem a php issue or a request issue?

Edit: I tried using urlencode / urldecode but those both failed to fix the problem. This also occurred with file_put_contents, so I’m starting to think it’s an upload problem.

  • 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-05-31T23:36:30+00:00Added an answer on May 31, 2026 at 11:36 pm

    The way to fix it is to URL-encode the text, which will turn % into %25. You’ll need to investigate where it needs to be encoded though (or why it’s not being encoded in the first place).

    >>> u'fi'.encode('macroman')
    '\xde'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with my index.php, i have this small script that decides
I have a small script that defines a variable called $prPrice . This script
I have this small piece of code that basically takes a list and runs
I have a small php script which allows me to upload image file on
So I have a small PHP script that generates an xml feel for the
I have a small problem with a script that reads an XML file and
I have created a small php script locally that runs a java application in
I have this small PHP script: <?php session_start(); $var = array(); $var['key'] = 'Var
I have this small jquery script that does not work if I remove the
I have this small code library that I'm considering releasing into Open Source. I

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.