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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:55:24+00:00 2026-05-29T08:55:24+00:00

I am asking the user to upload a file, through the following form making

  • 0

I am asking the user to upload a file, through the following form making a POST Request to another page Upload.php

<form name="input" action="upload.php" method="post" enctype="multipart/form-data">
    Username: <input type="text" name="username" /><br/>
    <input type="file" name="file" /> <br/>
    <input type="submit" value="Submit" />
</form>

At Upload.php, I use the data filled in the previous form to make an POST Request using Curl function for which I have written the following code:

$data = array(
        "username" => $username,
        "password" => $password,
        "title" => $title,
        "srcfile" => "@".$_FILES['file']['tmp_name']);

$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_URL, $api);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response=curl_exec($ch);

echo $response;

This way I am able to upload the file successfully but the file uploaded has a name without any extension which is set by this

$_FILES[‘file’][‘tmp_name’]

and thus I am not able to use the file on the server.

How should I use the file obtained from the POST Request to make another POST Request?

Thanks in advance.

  • 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-29T08:55:25+00:00Added an answer on May 29, 2026 at 8:55 am

    The problem in the above case is that though we can have the file using $_FILES[‘file’][‘tmp_name’], however, the file extension is not the same as that of original file and even the following code does not work which should run as filed in this bug https://bugs.php.net/bug.php?id=48962 in PHP 5.0

    "srcfile" => "@".$_FILES['file']['tmp_name'].";filename=".$_FILES['file']['name'].";type=".$_FILES['file']['type']
    

    I have finally used the following solution to solve the above problem:

    STEP 1: Save the file sent through the form’s POST request in a folder temporarily on the server or your machine.

    STEP 2: Now use the path where file has been saved temporarily to make a POST request using CURL for which the code is used same as above mentioned with changes in file location.

    "srcfile" => "@".temp_file_path
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic upload form: <form method=post action= enctype=multipart/form-data > <input type=file name=logo>
<html> <body> <form name=Upload enctype=multipart/form-data method=post> Filename: <INPUT type=file id=submit> <INPUT type=button id=send value=Upload>
I have a C# ASP.NET web page with an xml file upload form. When
My PHP book gives a template HTML form for uploading a file: <form action=upload.php
Instead of asking user to upload a video file - I want the user
in my php code I was asking the user to choose day, month and
I'm not asking about uploading a file from a browser to a php script,
If a website user submits an HTML form with: (1) a post method; (2)
I am preparing a application in which i am asking user to upload his
I am asking user to input a word then have my program compare it

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.