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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:40:31+00:00 2026-06-15T23:40:31+00:00

I am trying to create an upload plugin that allows for a user to

  • 0

I am trying to create an upload plugin that allows for a user to upload any file from their computer or from a url they type into the provided text field.

This is the script I have to upload files from a local disk:

session_start();
//Loop through each file
for($i=0; $i<count($_FILES['file']); $i++) {
  //Get the temp file path
  if (isset($_FILES['file']['tmp_name'][$i]))
  {
  $tmpFilePath = $_FILES['file']['tmp_name'][$i];
  }

  //Make sure we have a filepath
  if ($tmpFilePath != ""){
    //Setup our new file path
    if (isset($_FILES['file']['name'][$i]))
    $newFilePath = "./uploaded_files/" . $_FILES['file']['name'][$i];
    }

    //Upload the file into the temp dir
    if(move_uploaded_file($tmpFilePath, $newFilePath)) {

    echo "Uploaded Successfully!<br />";

}

All I need now is for the curl part to take the file from the url submitted in the text field and save it to the same location.

Here is the cURL I have so far:

function GetImageFromUrl($link) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_POST, 0);
    curl_setopt($ch,CURLOPT_URL,$link);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result=curl_exec($ch);
    curl_close($ch);
    return $result;
}

$sourcecode=GetImageFromUrl("http://domain.com/path/image.jpg");
$savefile = fopen('/home/path/image.jpg', 'w');
fwrite($savefile, $sourcecode);
fclose($savefile);
  • 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-15T23:40:32+00:00Added an answer on June 15, 2026 at 11:40 pm

    Is there a specific reason you want to use curl? Here’s how you can simply do that without it:

    $url = $_POST['url'];
    $file_content = file_get_contents($url);
    $file_name = array_pop(explode('/', parse_url($url, PHP_URL_PATH)));
    file_put_contents('/home/path/' . $file_name, $file_content);
    

    You should also consider looking into $url and checking if it’s valid before working with it.

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

Sidebar

Related Questions

I'm trying to create a plugin for nopCommerce v2.20 that allows the user to
I am trying to create an upload form that allows the user to select
I'm trying to create a script that will upload a file to a website.
I am trying to create a file upload field that has a little bit
I'm trying to create a simple Imgur app that will upload images to their
I am trying to create a PHP file to upload images to my website.
I am trying to upload a file with playframework. I create a form and
I'm trying to create a custom file upload control in WPF 4.0 and I'm
I'm trying to create an upload file, and email as an attachment form where
I'm trying to create file upload using iframe(ajax effect) but I need to know

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.