Current location: Hot Scripts Forums » Programming Languages » PHP » PHP - Transfer file from one server to another.


PHP - Transfer file from one server to another.

Reply
  #1 (permalink)  
Old 05-30-07, 10:11 AM
NabZ NabZ is offline
Newbie Coder
 
Join Date: Nov 2005
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
PHP - Transfer file from one server to another.

Could someone please give an example of how i could go about downloading a file from a website onto the server which my php script is located on.

For example;

i have a file here: http://example.com/file.zip
now i want to have a php script which will download that file onto the server which the script is located on.

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 05-30-07, 10:14 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
I wrote an upload class some time ago which can handle that.

http://www.bytemycode.com/snippets/snippet/528/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 05-30-07, 10:21 AM
NabZ NabZ is offline
Newbie Coder
 
Join Date: Nov 2005
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
hmm, isnt there a simpler way? i dont want to have code which is uneeded, and tbh im not too sure how to go about using ur class to do what i need.
Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 05-30-07, 10:27 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
PHP Code:

<?php


$url 
'http://www.example.com/file.zip';

if (@
copy($urlbasename($url)))
{
    echo 
'File saved.';
}

?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 05-30-07, 11:39 AM
NabZ NabZ is offline
Newbie Coder
 
Join Date: Nov 2005
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for that

Last edited by NabZ; 05-30-07 at 11:43 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 05-30-07, 11:45 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
You have to be careful if you use this in public. It does not check for file extensions or size limits.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Write to php file with php script or create new file, it is possible? Oskare100 PHP 10 08-14-08 10:03 AM
php upload file script xavier039 PHP 5 08-29-06 05:35 PM
how can call .exe(executable file) via or using php script on web server mohit Script Requests 0 08-03-06 02:59 AM
create php file on the fly and delete when session ends recedo PHP 0 01-06-06 11:28 PM
Need Help how to save file in server in PHP JTran PHP 1 04-21-04 08:29 AM


All times are GMT -5. The time now is 09:05 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.