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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:47:11+00:00 2026-05-28T01:47:11+00:00

I have a sample Restler class: class Author { …. function post($request_data=NULL) { var_dump($request_data);

  • 0

I have a sample Restler class:

   class Author {
      ....

      function post($request_data=NULL) {
         var_dump($request_data);
         var_dump($_FILES);
         var_dump($_REQUEST);

         return $this->dp->insert($this->_validate($request_data));
       }

      ....
  }

I’m trying to POST file and some data to Restler service by simple HTML form:

  <FORM action="http://host/index.php/author" enctype="application/x-www-form-urlencoded" method="post">
      Name:  <INPUT type="text" name="name" value="dima"><BR>
      Email: <INPUT type="text" name="email" value="dima@prot.lt"><BR>
      File:  <INPUT type="file" name="files"><BR> 
      <INPUT type="submit" value="Send"> <INPUT type="reset">
  </FORM>

It is clear, that the $_FILES array will be empty, but $_REQUEST and $request_data will have three variables:
name = "dima", email = "dima@prot.lt" and file = "selected file name".

In the next test, I changed the form enctype value to multipart/form-data.

  <FORM action="http://host/index.php/author" enctype="multipart/form-data" method="post">
      Name:  <INPUT type="text" name="name" value="dima"><BR>
      Email: <INPUT type="text" name="email" value="dima@proto.lt"><BR>
      File:  <INPUT type="file" name="files"><BR> 
      <INPUT type="submit" value="Send"> <INPUT type="reset">
  </FORM>

When I press submit form, in the $_REQUEST array, I will see the same three variables, the $_FILES array will be filled with uploaded file information, BUT the $request_data array will be empty!!

Can anybody help in this situation? Where have I made a mistake?

  • 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-28T01:47:11+00:00Added an answer on May 28, 2026 at 1:47 am

    I have solved this issue, by writing Restler plugin, may be other will have the same problem:

    <?php
    
    /**
     * URL Encoded String in multipart data format
     * @category   Framework
     * @author     Dmitrij Orlov <dmitrij.orlov@gmail.com>
    */
    class UrlMultipartFormat implements iFormat
    {
        const REQUEST_MIME      = 'multipart/form-data';
        const RESPONCE_MIME     = 'application/json';
        const EXTENSION         = 'post';
    
        public function getMIMEMap() {
            return array(self::EXTENSION=>self::REQUEST_MIME);
        }
    
        public function getMIME(){
            return self::RESPONCE_MIME;
        }
    
        public function getExtension(){
            return self::EXTENSION;
        }
    
        public function setMIME($mime){
            //do nothing
        }
    
        public function setExtension($extension){
            //do nothing
        }
    
        public function encode($data, $human_readable=FALSE){
            return $human_readable ? 
            $this->json_format(json_encode(object_to_array($data))) : 
            json_encode(object_to_array($data));
        }
    
        public function decode($data){
            return $_REQUEST;
        }
    
        public function __toString(){
            return $this->getExtension();
        }
    
        /**
         * Pretty print JSON string
         * @param string $json
         * @return string formated json
         */
        private function json_format($json)
        {
            $tab = "  ";
            $new_json = "";
            $indent_level = 0;
            $in_string = FALSE;
    
            $len = strlen($json);
    
            for($c = 0; $c < $len; $c++) {
                $char = $json[$c];
                switch($char) {
                    case '{':
                    case '[':
                        if(!$in_string) {
                            $new_json .= $char . "\n" . 
                            str_repeat($tab, $indent_level+1);
                            $indent_level++;
                        } else {
                            $new_json .= $char;
                        }
                        break;
                    case '}':
                    case ']':
                        if(!$in_string) {
                            $indent_level--;
                            $new_json .= "\n".str_repeat($tab, $indent_level).$char;
                        } else {
                            $new_json .= $char;
                        }
                        break;
                    case ',':
                        if(!$in_string) {
                            $new_json .= ",\n" . str_repeat($tab, $indent_level);
                        } else {
                            $new_json .= $char;
                        }
                        break;
                    case ':':
                        if(!$in_string) {
                            $new_json .= ": ";
                        } else {
                            $new_json .= $char;
                        }
                        break;
                    case '"':
                        if($c==0){
                            $in_string = TRUE;
                        }elseif($c > 0 && $json[$c-1] != '\\') {
                            $in_string = !$in_string;
                        }
                    default:
                        $new_json .= $char;
                        break;
                }
            }
    
            return $new_json;
        }
    
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this sample text, which is retrieved from the class name on an
I have this sample code for async operations (copied from the interwebs) public class
I have sample code like this: <div class=cart> <a onclick=addToCart('@Model.productId'); class=button><span>Add to Cart</span></a> </div>
I have sample XML like this: <users> <user name=user1> <roles separator=,>ADM,USER</roles> </user> <user name=user2>
I have a sample class: class SampleClass { public virtual string SomeProperty{get; set;} public
I have this sample page: <html> <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8> <title>Ajax Page</title> <script
I have this question: Does implementing a custom MembershipProvider class needs you to implement
I have sample DOM: <div class=x> <div class=y> <span>a</span> <span>b</span> <span>c</span> </div> <div class=y>
I have sample data like this df <- data.frame(name = rep(letters[1:7], each = 24),
I have sample div structure: <div id=outer style=width:600> <div class=inner></div> <!--row1--> <div class=inner></div> <div

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.