PHP File Upload

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
LVL 4
k4hvd77Asked:
Who is Participating?
 
venkateshwarrCommented:
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
 
venkateshwarrCommented:
why dont you write a script to download the file to your server.
Whatever php you write will run on the server itself..
0
 
k4hvd77Author Commented:
I have no experience with php!  Could you send me some Examples how to do something Like that?


k4hvd77
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
k4hvd77Author Commented:
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
 
venkateshwarrCommented:
your directory does not have write permissions...
0
 
k4hvd77Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.