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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:50:07+00:00 2026-05-31T21:50:07+00:00

I had a working relationship with a Java server and a PHP server using

  • 0

I had a working relationship with a Java server and a PHP server using curl from php.

Using curl I sent over an array with image data and some string vaules.

In PHP, the image was taken directly (tmp storage) from a HTTP POST form and put in the array, successfully. But now I need to move_uploaded_file first to a specified directory and read it back with fopen into another PHP document that use curl.

The only difference is that I used $_FILES[“photo”][“tmp_name”], and now I use fopen. Code:

// $image = $_FILES["photo"]["tmp_name"]; Had success with this one from FORM POST
// $filename = basename($_FILES['photo']['name']);

$filename = $_POST["filename"]; // file name from ajax post

$image = fopen('C:\\xampp\\htdocs\\app\\uploads\\'.$filename, "rw"); // the sinner?

$data = array(
    'uploaded_file' => '@' . $image . ';filename=' . $filename,
);
....
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url); // the Java web service URI
curl_setopt($c, CURLOPT_HEADER, false);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $data);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);

$output = curl_exec($c);

Error:

Erreur curl : couldn't open file "Resource id #3" 
Array
(
     [uploaded_file] => @Resource id #3;filename=480x_13197743.jpg
)

EDIT:

I printed the array from the working solution, and it points to the file/resource differently:

Array
(
    [uploaded_file] => @C:\xampp\tmp\php20EA.tmp;filename=magn.png
)

Or better said, it has just a file path string. Ok, so that fixed it, using just the file path, and disregarding any copy of binary data. Answered my question =|

  • 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-31T21:50:09+00:00Added an answer on May 31, 2026 at 9:50 pm

    See the “Uploading file” example at http://php.net/manual/en/function.curl-setopt.php

    Simply specify the file path in your array, not a resource handle fopen returns.

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

Sidebar

Related Questions

I had a working solution using ASP.NET MVC Preview 3 (was upgraded from a
I had a problem working with the image classes in java. I am creating
I had started working on GPGPU some days ago and successfully implemented cholesky factorization
I had been working on server side(c#) for a couple of years. But now
I had a clean working directory and brought in a clone from a Git
I'm currently developing application using DirectSound for communication on an intranet. I've had working
Hey guys I've been using the has_and_belongs_to_many relationship with checkboxes example from the Railscast
So, I'm using SQL Server Management Studio Express,it has been working not bad so
I'm working with a legacy application that makes some use of the well-known/dreaded data
I'm working on a web project. I'm using a Sql Server 20008 R2 database

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.