Solved

PHP File Upload

Posted on 2004-04-24
6
642 Views
Last Modified: 2008-02-07
Hello PHP Experts,

is there any way to upload a file using PHP from a Remote Server? for Example I would upload a file from another Server (ftp or Http) to my server.

k4hvd77
0
Comment
Question by:k4hvd77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 12

Expert Comment

by:venkateshwarr
ID: 10909144
why dont you write a script to download the file to your server.
Whatever php you write will run on the server itself..
0
 
LVL 4

Author Comment

by:k4hvd77
ID: 10909175
I have no experience with php!  Could you send me some Examples how to do something Like that?


k4hvd77
0
 
LVL 12

Accepted Solution

by:
venkateshwarr earned 125 total points
ID: 10909994
try this...

<?php
$userfile="http://www.google.com/index.html";
$copyfile="index.html";
if(file_exists($userfile)) { echo "File already exists"; }
else
{
copy($userfile,$copyfile);
print "File downloaded";
}
?>

0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 4

Author Comment

by:k4hvd77
ID: 10911123
got following:

Warning: copy(index.html): failed to open stream: Permission denied in /home/k4hvd/public_html/PHPDocument1.php on line 7
File downloaded
0
 
LVL 12

Expert Comment

by:venkateshwarr
ID: 10912634
your directory does not have write permissions...
0
 
LVL 4

Author Comment

by:k4hvd77
ID: 10912677
thank you venkateshwarr,

I have just 2 other questions ( 125 points Extra),

- How to do it by postnig Data? for example (downloadfile.php?filename=http://www.google.com/index.html&Saveto=index.html )

- I would know how Long does it take to download the file ( for example 0,001 seconds )


0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question