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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:24:51+00:00 2026-05-26T00:24:51+00:00

I’m using Luracast’s Restler Framework which is great. But I was wondering if someone

  • 0

I’m using Luracast’s Restler Framework which is great. But I was wondering if someone could tell me how I can upload files through HTTP.

I was using a simple HTML Form to POST data to the API, and trying to grabe the file information from $_FILES, but i’m not getting anything.

Here is my super simple form

    <form method="post" action="index.php/product"> 
    <p> 
        <label>Product name</label>
        <input name="product_name" /> 
    </p>

    <p> 
        <label>MSRP Price</label>
        <input name="msrp_price" /> 

    </p>


    <p> 
        <label>Category</label>
        <input name="category_name" /> 
    </p>


    <p>Teir Pricing</p>


    <p>
    <label>Price</label>
    <input name="price[]" />
    </p>


    <p>
    <label>Buy Range Min</label>
    <input name="buy_range_min[]" />
    </p>

    <p>
    <label>Buy Range Max</label>
    <input name="buy_range_max[]" />

    <p>
    <label>Price</label>
    <input name="price[]" />
    </p>

    <p>
    <label>Buy Range Min</label>
    <input name="buy_range_min[]" />
    </p>

    <p>
    <label>Buy Range Max</label>
    <input name="buy_range_max[]" />
    </p>


   <p> 
    <label>Image</label>
    <input type="file" name="image" /> 
   </p> 

    <input type="submit" /> 

</form>

Here is my class that works with Restler

<? 



class Product {
        public $dp;
        private $DBH; 
        public $highest_max = 0; 


        function __construct() { 

            $host = 'localhost'; 
            $db_name  = '';  
            $db_user = '';  
            $db_password = ''; 

                try {  
                  $this ->DBH = new     PDO('mysql:host='.$host.';dbname='.$db_name, $db_user, $db_password);

                  // Line takes care of error reporting.   
                  $this->DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); 
                }  
                catch(PDOException $e) {  
                    // return $e->getMessage();

                    return 'Sorry there was an issue';   
                } 
        } // end function 


        function get($id=NULL) {
            if (is_null($id)) { 
                /*** The SQL SELECT statement ***/
                $sql = "SELECT * FROM products";

                 $data = array('product_id' => $id); 

            $STH = $this->DBH->prepare($sql);
            // binds the params  
            $STH->execute($data);
            // wHAT TYPE OF DATA WE ARE GRABING 
            $STH->setFetchMode(PDO::FETCH_ASSOC);

                // GO TRough IT ALL 
                while($row = $STH->fetch()) { 
                    $rows[] = $row; 
                } // end while 
                return $rows; 
            } // end if 

            else { 
                $sql = "SELECT * FROM products WHERE product_id = :product_id";

                 $data = array('product_id' => $id); 

            $STH = $this->DBH->prepare($sql);
            // binds the params  
            $STH->execute($data);
            // wHAT TYPE OF DATA WE ARE GRABING 
            $STH->setFetchMode(PDO::FETCH_ASSOC);

                $row = $STH->fetch();   
                return $row; 

            } // end else 
        } // end function 



            function add_teir_pricing($price, $buy_range_min, $buy_range_max, $product_id) { 

                // check to see if the min is higher then this max
                if ($buy_range_min >= $buy_range_max) { 

                    throw new RestException(417,'Your min price teir must be smaller then your max' );
                } // end if 


                elseif ($buy_range_min <= $this->highest_max) { 
                    throw new RestException(417,'One of your minimum price teirs cannot overlap with another.' );
                } // end if 


                $this->highest_max = $buy_range_max; 


            # the data we want to insert  
$data = array( 'price' => $price, 'buy_range_min' => $buy_range_min, 'buy_range_max' =>      $buy_range_max, 'product_id' => $product_id );  


            $sql = "INSERT INTO teir_pricing (price, buy_range_min, buy_range_max, product_id, created) value (:price, :buy_range_min, :buy_range_max, :product_id, NOW())"; 


            $STH = $this->DBH->prepare($sql); 


            $STH->execute($data);


    } // end function 

        function post($product_id=NULL,$member_id, $product_name, $upc_code, $sku, $global_trade_item_number, $link_to_product_reviews,
                     $url_to_product,
                     $msrp_price,  
                     $category_name, $price, $buy_range_min, $buy_range_max) {

                    // ADD PRODUCT 
                    if (!isset($product_name)) { 
                        $error = true; 
                        // $errors['message'][] = 'Mising a product_name'; 
                        throw new RestException(417,'Mising a product_name');
                    } // end if 

                    if (!isset($msrp_price)) { 
                        $error = true; 
                        // $errors['message'][] = 'Mising a msrp_price'; 
                        throw new RestException(417,'Missing MSRP price');


                    } // end if 


                    if (!isset($category_name)) { 
                        $error = true; 
                        // $errors['message'][] = 'You must assign a category_name to this product'; 
                        throw new RestException(417,'You must assign a category_name to this product');
                    } // end if 


            // We still need to grab the member id from the key when this is added.         
            $member_id = 1; 





            $product_data = array('member_id' => $member_id, 
                                  'product_name' => $product_name, 
                                  'upc_code' => $upc_code, 
                                  'sku' => $sku, 
                                  'global_trade_item_number' => $global_trade_item_number, 
                                  'link_to_product_reviews' => $link_to_product_reviews, 
                                  'url_to_product' => $url_to_product, 
                                  'msrp_price' => $msrp_price,  
                                  'category_name' => $category_name); 


            $sql = "INSERT INTO
                    products
                    (product_name, 
                     upc_code, 
                     sku, 
                     global_trade_item_number, 
                     link_to_product_reviews,
                     url_to_product,
                     member_id,
                     msrp_price,
                     created, 
                     category_name)

                    VALUES
                    (:product_name, 
                     :upc_code, 
                     :sku, 
                     :global_trade_item_number, 
                     :link_to_product_reviews,
                     :url_to_product,
                     :member_id,
                     :msrp_price,
                     NOW(), 
                     :category_name 
                     )"; 

            $q = $this->DBH->prepare($sql);  

            $q->execute($product_data); 

            $product_id = $this->DBH->lastInsertId(); 



            foreach($price as $key => $value) { 
                Product::add_teir_pricing($price[$key], $buy_range_min[$key], $buy_range_max[$key], $product_id);

            } // end foreach 

$response = array('product_id' => $product_id, 'status' => 'success', 'message' => 'Your product has been added', 'files' => $_FILES); 

            return $response;           
    } // end function 


    function upload_image($_FILES) { 

        return $_FILES; 

    } // end function 

} // end class 

?>

  • 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-26T00:24:52+00:00Added an answer on May 26, 2026 at 12:24 am

    You can only upload files if the form data is sent as multipart/form-data. The default is application/x-www-form-urlencoded.

    From the specification:

     <FORM action="http://server.com/cgi/handle"
           enctype="multipart/form-data"
           method="post">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the

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.