PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 19th, 2000, 03:57 AM
Aoeex Aoeex is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 24 Aoeex User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 51 sec
Reputation Power: 0
I am trying to set up a link excahnge program using php and I need to know how to copy a file from one server to another. See when people change the banner they have displayed they can enter the location of their banner, such as http://them.com/banner.gif and then i need to copy it over to my server and into there dir, such as www.me.com/them/banner.gif.
Does anyone know how i can do this. I have tried many things but nothing has workd so far

[This message has been edited by Aoeex (edited June 19, 2000).]

Reply With Quote
  #2  
Old June 19th, 2000, 09:05 AM
alexgreg's Avatar
alexgreg alexgreg is offline
Full Access
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jun 2000
Location: London, UK
Posts: 2,019 alexgreg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 sec
Reputation Power: 15
Try something like this: Have a form that posts to the PHP program...

<form method=POST action="copy.php3" enctype=multipart/form-data>

URL of your current banner:
<input type=text name=banner><br>

And the name of your folder:
<input type=text name=folder><br>

<input type=submit name=submit>

</form>

</body></html>

The PHP program would then look like this:

<?
print "Please be patient, this may take a few seconds...";

copy($banner,"full/path/to/$folder/banner.gif");

print "Done!";

?>

This should work. It'll only work if they know what their directory is ("them"). Their directory would also have to exist on the server already: I don't know how do create directories in PHP. Each banner must also be called banner.gif

--------------------------
Alex Greg
(http://www.alex-greg.co.uk)

Reply With Quote
  #3  
Old June 19th, 2000, 03:18 PM
Aoeex Aoeex is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 24 Aoeex User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 51 sec
Reputation Power: 0
Thanks for the idea but when I tried it I got the same error i did when I tried using the copy () function. This is the error it returns
Warning: Unable to open 'http://www.geocities.com/aoeex/aoeex.jpg' for reading: No such process in
c:home2k-okeithmpublic_html/linkx/copyfromnet.php3 on line 24
I think that PHP's copy() can't accept http:// urls, only file system. So I am guesing that I will have to make my own class/function to copy the file.

Oh and just if you would like to know you can use the mkdir function to make a directory

ex. if(mkdir("/newdir",0777)){ echo "Dir made, Permission set to 777"; }

Reply With Quote
  #4  
Old June 19th, 2000, 10:36 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Try fopen.
Do you really wanted to save the banner locally (waste of disk space) or preferably fetching the banner on demand (per request)?

Reply With Quote
  #5  
Old June 19th, 2000, 10:50 PM
Aoeex Aoeex is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 24 Aoeex User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 51 sec
Reputation Power: 0
I do actully need to pull the pic of there server and onto mine for now. I know it is a wast of space but I might try a few thins later on which will help with that.

I don't know about the fopen thoug. havn't really tried anything like that before. I had tried using the file() function to save it into an array but that didn't work. Do ya think mayb if i open both file at the same time and write to one and i read the other it will work?

Something like
$fd=fopen($them,"r");
$fd2=fopen($me,"w");
might work. I'll have to try it later on

Reply With Quote
  #6  
Old June 20th, 2000, 12:27 AM
Aoeex Aoeex is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 24 Aoeex User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 51 sec
Reputation Power: 0
Well i finally got it. If anyone wants it the code that i came up with is

<?
if ($banner){
print "Please be patient, this may take a few seconds...<BR><BR><BR>";
$them=$banner;
$me="/path/to/file/$localname";
$fi=fopen($them,"r");
$fl=fopen($me,"w");
while(!feof($fi)){
fwrite($fl,fread($fi,15360));
}
fclose($fl);
fclose($fi);
chmod($me,0644);
print "<BR><BR><BR>Done!<BR>

exit;
}
?>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Copying Files from onserver to another

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap