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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:29:16+00:00 2026-06-09T19:29:16+00:00

I am using PHP 5.3.6 and it seems I am unable to make a

  • 0

I am using PHP 5.3.6 and it seems I am unable to make a PUT request using CURL for PUTting just a string.

function put_data($url, $data)
{   
  $useragent="SimpleAgent-1.0";
  $fh = fopen('php://memory', 'rw');
  fwrite($fh, $data);
  rewind($fh);$ch = curl_init();
  curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
  curl_setopt($ch, CURLOPT_INFILE, $fh);
  curl_setopt($ch, CURLOPT_INFILESIZE, strlen($data));
  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  curl_setopt($ch, CURLOPT_PUT, 1);
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $result = curl_exec($ch);
  curl_close($ch);
  fclose($fh);

  return $result;
}

Here, $data is the string that I want to PUT.
Doesn’t work and returns the following error:

500 Internal Server Error The server has either erred or is incapable
of performing the requested operation.

expected string or buffer

  • 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-09T19:29:18+00:00Added an answer on June 9, 2026 at 7:29 pm

    I am only able to pass the array as a data with the versions I am using. So this is what I am doing now:

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
    curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);
    curl_setopt($ch, CURLOPT_COOKIE, $curl_cookie);
    $arr = array();
    if (isset($data)) {
        $arr['my_data'] = $data;
    }
    
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));
    curl_exec($ch);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to send a Javascript array to PHP using AJAX. This seems very
I'm busy implementing the wurfl api using PHP, but somehow just can't seem to
Using php I am trying to get some data from a .csv file which
PHP seems to use a rather annoying method for setting the evnironment timezone, using
I'm trying to validate usernames in PHP using preg_match() but I can't seem to
Using PHP I echo out table rows in a loop like this: <?php /*
Using PHP I'm trying to download/save the following image: http://www.bobshop.nl/catalog/product_image.php?size=detail&id=42428 When you load this
Using PHP, I am making an application similar to an online concierge service. I
Using PHP 5.3.3, PostgreSQL 8.4.11, pgbouncer 1.3.4 (in session mode) on CentOS 6.2 I'm
Using PHP 5.2.4 and the OpenSSL 0.9.8g module I am trying to create a

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.