Solved

PHP File Upload

Posted on 2004-04-24
6
637 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

867 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now