Solved

PHP File Upload

Posted on 2004-04-24
6
639 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
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…
The viewer will learn how to count occurrences of each item in an array.
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…

786 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