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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:15:25+00:00 2026-06-11T17:15:25+00:00

I have made this script for uploading remote files but the file is not

  • 0

I have made this script for uploading remote files but the file is not uploaded to server and the database for var1 remains empty. Here is my code.

HTML:

<form enctype="multipart/form-data" id="form1" method="post" action="">
    <p><label>Upload songs</label>      
    <input type="text" name="song"><input type="submit" value="Submit" class="button"></p>
</form>

PHP:

$uri = copy1_file($_POST['song']);
$story['v1'] = $uri;

        $url = $_POST['song'];
    $file = fopen ($url, "rb");
    if ($file) {
        $newf = fopen ($uri, "wb");
        if ($newf) {
            while(!feof($file)) {
                fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
            }
        }
    }
    if ($file) {
        fclose($file);
    }
    if ($newf) {
        fclose($newf);
    }
    else {
        return false;
    }
}

I have checked the error log but nothing is coming. Where I am doing a mistake?

  • 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-11T17:15:27+00:00Added an answer on June 11, 2026 at 5:15 pm

    Read up on PHP File Uploads.

    Try this to debug your script:

    var_dump($_FILES);
    

    Do you see anything?

    EDIT: Okay, I see you more clearly defined “remote files.” You have to use a “text” input to receive the URL. How did you get around the standard file selection dialog?

    It looks like your code will work as-is if you just change the <input/> type to “text”.

    EDIT 2: I noticed you updated your post to have <input type="text"/> so you already have a URL making it through to your script. Check to see if your host has allow_url_fopen enabled. If not, your URL will not be retrieved by fopen(). You will have to use cURL instead.

    EDIT 3: Could it be that your copy1_file function never actually returns the uri? There are a lot of errors in the code in that function. Ex: copy1_file is receiving a url, why does it have $file['name'] at the top? And later reference $_POST directly? There are more errors. Check it closely and correct them, then it should work fine since you say fopen(url) is known to work with your host.

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

Sidebar

Related Questions

Hi I have recently made this script to rename files I scan for work
I have this script: http://jsfiddle.net/NV2uV/ It works, but I do not like it. Cons:
I have made this infinitely scrolling script, but I can't rebind the window scroll
I have made this timer script but I can't seem to make it so
Hi, I have made this simple script but I need to have it check
I have made this script to open a fancybox from code behind, but it
i made this script that add in a mysql database information about who have
I have made this code to open a database(created in SQLite browser) stored in
I am developing a script in PHP for uploading files to a MySQL database.
I have made this script $(document).ready(function(){ $(div#tabs a).hover(function(){ rod = this.id $('div.tabber').hide(); $('#tabber_' +

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.