Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Copying Files From One Server To Another


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.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Copying Files
The situation is I have a template.php file, and I wan't my script to copy this file and give the new copy a new name.

This is the code so far, but it doesn't copy...

$temp = "template.php";
$file = $linktextdata . ".php";

if (!copy($temp, $file)) {
echo "copy of $temp failed";
}

I test echoed the variables, and they look ok.

Copying Remote Files
How do i copy a picture or another file from a remote webpage, and put it into my webpage dir?

Files And Folder Copying
I am trying to write a function to copy an existing folder and folder
structure but am already stuck.

What I want to do is the following:

Copy a default folder (default_folder) and all sub folders within it (down
to a possible 4 levels)
eg default folder
->subfolder1
->subfolder2
->sub subfolder1
->sub sub folder 2

I have a form where the user can enter the name of the new folder and an
option to confirm if they want to copy the files also located within the
default folder.
If the checkbox is not checked then copy just the folder structure only

Can this be acheived in one function or will it be based on 2 where a set of
empty folders are created and where the folders and files are copied over

Copying Files Using A Loop
I have a spreadsheed with names and image urls that I have converted to a tab delimited text file. Column one has the product  name and column two has a url to an image on another site.

I am trying to loop through the file and copy the image onto my computer, but it is giving me this error: "Warning: copy(http://ec1.images-amazon.com/images/I/41Oj92a63gL._AA280_.jpg ) [function.copy]: failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in C:Program Filesxampphtdocscopy.php on line 16" Code:

Copying A File From On Server
Let's say I have a file on my server at location:

/public_html/Global/oilers.php

...and i want to copy this file and save it to another directory (using ftp commands):

/public_html/hockey/Oilers/oilers.php

How would I go about....   I gigured out how to login using ftp commands and explored the ftp command available.. (eg.put, get etc..) but I'm not sure which command to use..  can someone point me in the right direction?

Error While Copying Files After Upload
I'm trying to allow users to upload to the server. The system seems to upload okay (at least it takes a while for the page to refresh after the submit button is pressed). When the submit button is pressed and the files are uploaded, it reloads the script (a $PHP_SELF in the form tag).

What happens next is that it tries to copy the uploaded files (a maximum of 3 files can be uploaded) to a more permanent directory on the server. code:

Files Move From Server To Server
I moving to a new server. Is there a way that I can do this without downloading all my files and uploading them? Is there a script that can do this?

PDF Files On The Server
I create pdf files on my unix server using php and a very useful utility from http://ros.co.nz/pdf/.
Due to many IE problems I have found the best way is to save them to disk rather than streaming them and then redirect the user using javascript.
The problem is that the file is then on the server. I can write a cron to delete the files every so often but the files contain sensitive information so I would not want them to be accessed by just anyone.
My main site is password protected through php and mysql. I have thought of using .htaccess files but then the user is asked for a username and password even though they are logged in to my system. Is there anyway of securing these files?

Uploading Files To Sql Server
I'm trying to upload files (into an image field) and then download them, but my files are reduced to 4096 bytes after the downloading. I've tried to execute the query "set textsize=60000" before each select, but this seems to have no effect. I read the files and execute the queries from php 4.2.4.

Transporting Php Files To A Mac-server?
Run into some problems when transporting my php filez to a mac server (it is unix based, right???). Somehow, some of my variables (1 out of 3) would not show up. I needed 3 vars to make a mysql-query. I fixed it by using $_REQUEST['var'] for just one variable, but for the other variables i did not use it and it works.

Deleting Files From A Server
As part of a project I want to allow users to save files to a server or delete files from a server. I have the uploader working fine, but i have no idea how i would delete the file from the server.

Uploading Files To A Web-server
So here's the deal; I'm hosting several people on a virtual server
running Linux (White Box Enterprise), each of which has an internet
presence. (Apache webserver.) They're also web novices. I want to
develop a method by which they can upload photos to a folder on the
server from their client computer, without having to use FTP, creating
the folder if necessary. This would be accessed from the client-side
from a signed applet. How could this be done, short of granting
univeral write access in the folder? Is there a way (for instance)
that a user can access their remote account with the rights of their
local user? I.E., as if they'd logged in via FTP? This should run as
quietly as possible, not requiring HTML forms and the like.

I'm new to Apache programming, so I'd appreciate any links to
possibilities for doing this, or any projects that've already done it.

Server Generated PDF Files?
Heres what I need to happen now, I know how to do most of it, except the generated PDF form.

- The server puts that information into a PDF file with a background of my chosing and emails it to a specified adress. (Its already set up to send the email)

My issue is I dont know how to have the server generate the PHP form. How does it work? How do I position the text over the PDF automatically?

I'm already donating $10 to the site, thanks to the help I received from UTAlan, Lytheum, and Waldir. Ill make it a total of $20 after this.

Selecting Files From Server With Php
I made a little app that opens a html file into fckeditor then after edit saves the html file. I would like to add a drop down list or whatever is best, so i can select from files on the server to edit. How would I accomplish this
task.. in the simplest form since I am a newbie..

Saving Pdf Files To The Server
I am trying to save pdf documents to the server. I would prefer that it is not shown to the user. What I am trying to achieve is to create a pdf, save it to the server, and then email it as an attachment

Is this possible, and if so How is it done?

Including Files In Remote Server
I have a perl script to grap headlines from slashdot and such for me, and I use corn to have it run hourly and put the headlines in a file on the linux server.

Now problem is that my site is sitting on a Windows 2000 Apache Server. So I can't seem to use include() to get the file into my page. Any suggestions or alternatives?

Delete Files On Server Using Browser
I have several php files in a folder. I would like to have the possibility of deleting these files using my browser, rather than having to log onto the server and do that.

Reason? I am dealing with a slightly slippery client, in case he changes the password after i have put the entire site on it, i would like to be able to delete my files, in case i get stiffed on the payment.

Would appreciate any pseudo code/code on getting this done, if possible.

Nobody User When Upload Files On Web Server
This time I've got a terrible big problem about
the interaction between a PHP application and the web server filesystem.

The PHP application has got many funtionalities, such as uploading small image or text documents, creating directories, and so on.
Once I log on the web server filesystem, I notice that
all the files have been uploaded correctly, but their ownership is of "nodody" user, "nobody" group and 754 permission.

I would like such files should have the same owner of the web files on the server, i.e. "pippo".

Moving Files On A Linux Server
I need to find a way of moving files on my linux server using PHP. Because of security the folders I am moving files to require you to be logged in as the super user.

Problem Using PHP For Server Files Redirect
We are trying to set up a PHP page to handle server requests for
individual web pages that we are moving to a new server. The part that
complicates this procedure is that the files will not be mirrored on the
new server. Instead many will be residing in new directories and
subdirectories than they were in on the old server.

What we wanted to do was when someone requested a specific page from our
old server, it would recognize the non-existent page and send it to the
redirect.php page that we created. That part works fine. Unfortunately,
PHP is unable to see what page originally was requested. I thought it
would see one page back, but it doesn't.

Is there any way to get the redirect.php to identify what the called for
page was so it can redirect it forward to the place the file resides in
on new server properly? I know this would be simple if this was from a
form but it's not.

Generating A List Of Files On Another Server
I have been messing about with the folder / file functions on the php.net website but they all seem to be for local folders.

All I am trying to do is generate a list of files on another servers folder - so my variable to generate a list from would be "www.tnauk.org.uk/bbs/daily" but the script would be running on nimmox.com. Is it possible?

Saving Uploading Files On The Server
i am about to start writing a script that uploads files to my server.
the code for the form i want to use is:

<form enctype="multipart/form-data" action="savefile.php"
method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>

using the action script (savefile.php), how do i them save the file in
a folder on the server?

500 Server Error Loading Php Files W/iis
I'm sure this question has been asked many times, but I couldn't find a thread that related to my setup, so I have to ask. I have a Windows XP pro machine setup w/IIS 5.1. I've got html, perl, and asp pages setup and working fine. But for some reason, I keep getting a file not found/500 server error when I try to load a simple php file.

I tested the file in the command prompt and it outputted the results as expected, so I know it's not a php problem. I'm using the dll file that I copied into the windows/system folder to load the scripts and setup a application configuration and filter setting, and stopped/started IIS. Same error.

Script That Can Run Executable Files On A Server
I am looking for a script that can run Executable files on a server, I have leased a dedicated server but the company doesn't allow remote desktop access to it, so I can't run them, we have uploaded server files to a dedicated server but can't run them, they are exe files.

Image Copying
I have this form tag to send an image to my message board: <input type=file name=picture> and the enctype="multipart/form-data" in in the form tag. I them use $picure_name to do two things.

First, I alter the message the include the img tag using str_replace. That part works fine. I then try to copy the message to the images directory:exec("cp $picture /full/path/to/mbimages/$picture_name");

The image never gets there. I don't get any error messages, but the image never shows up in that directory.

Copying A Directory
I think i can use copy() to do this, but i just dk how :S.  i can only get it to copy files.

I need a script that can copy a folder, and all the files in that folder, and "paste" it in a new directory. 

Required Files Confused Between Applications On Same Server
I'm running PHP 5.2.0 on my Windows XP laptop, running under IIS. I
have files named 'config.php' in two different web applications on
this machine, which are included throughout each via 'require' in one
and 'require_once' in the other.

When I attempt to use the two applications simultaneously, the file
which was 'require_once'-ed is also being accessed from the other
application, even though the two applications are isolated from each
other in IIS, and are in completely different directories on the
computer.

Uploading Mp3 Files To Folder On Server Via Php Form..
Im trying to design a webpage form in php that allows uploading of three mp3 files to a folder on my server. The webpage should convert the name of each mp3 file uploaded to 1.mp3 , 2.mp3 and 3.mp3 and whenever a new song is uploaded it should replace whatevers in the folder on the server, im totally stuck as where to begin.

Copying From One Mysql Database To Another
Is it possible to open a connection to two separate mysql databases in order to copy the data from one table in the first database into a table in the second database? I'm assuming the answer is yes, but I'm confused as to the proper php syntax.

Copying Entire Directories
I need to copy all of the files from one directory to another. This has to happen on the fly. The files that are being copied are actually templates for another site that will be created. I have seen the example on php.net under the fopen section but it doesnt work.

Copying Rows To Another Table
After I select a row whose ID is 10 or some other number, I need to
copy the entire row into another table.

Is there a way to copy rows between tables using PHP? Could someone
please point me to an example..

Copying Old Folders To A New Location
I'm trying to write a page that would make a copy of a set of folders to a new location for an intranet. There is lots in the page for debugging that would vanish once I get it to work. The problem I'm getting is I cannot get XCOPY to work. Other dos commands work fine. Code:

CopyDir (Copying One Directory To Another)
I was wondering if it was posible for someone to point me in the right direction.

What i need to do it copy the contence of an entire directory to another designated destination, is this possible and if so could someone point me somewhere i where i can figure it out.

Download Files From Remote Server To Local Webserver
I am trying to create a php page whereby people can download files from a remote server to their own server (to update their webdirectory with updated files/images etc). So for example one php page (e.g. update.php) should be able to download files from a remote server to a specific directory on their local webserver. Is this possible?

Copying Values From One Table To Another Problem?
I'm trying to copy some values from 10 tables to one table.

So i made a PHP script to do it automaticaly every time the user select an specified option.

Copying A Multidimensional Array To $_SESSION
Specifically, is it possible to copy a multidimensional array into the
$_SESSION array - ie a deep clone of all keys and data?

I naively assumed that

$_SESSION["myArray"'] = $myArray ;

would work but it doesn't appear to work. Is there a single function
or assignment I can use, or would I need to use a "foreach" at every
level?

Copying Variable Part Of A String
I have strings like these:

$line = "Item <name> xxx stock, costs yyy and will sell for amount zzz";

Problem is <name> can consist of 1..n words. Most items are single words,
but some are up to 8 in my example, and there are is no set maximum (well,
max is 80 chars I believe, have to look in the stock db, not too relevant I
think)
I found this out the hard way. I thought I was clever (never do that again)
by doing this:
$words = explode (" ", $line);
$itemname = $words [1];

This only works for single-word names.

Now I want to create or use an existing function that simply copies
everything between Item and the first numerical substr.
The function then should look like:

$itemname = GetSubStr ("Item" , <numerical> , $line);
<numerical> should be a template of some sort I think.

Controlling The Copying Of Images From A Site
Is there a way to prevent users copying a full size image from a web page.
Displaying the image with a smaller width and height only affects the image
as viewed, the actual full size image file is still downloaded. I know I can
get around it by having two versions of an image, the full size one and a
smaller on for display purposes. but is there a way around having to have
two images and use the full ssize one and stop it being copied or if copied
will only be a thumbnail?

Making A Database Backup To Local Server And Upload Files To Another?
I want to make a script that backups the *.frm and *.MYD files to my server and I also want to upload those files to another server via FTP? I have a copy of the database files in the directory, that works fine. But my ftp part doesn't! PHP Code:

User Uploading Files To Load Balanced Server Cluster
This really is a file permissions problem ... although I'm not sure how
to solve it. Any assistance would be greatly appreciated.

I have a series of load balanced servers. Each of the servers is
arranged exactly the same and handles file uploads from users as
follows:

1) User submits file to www1 server
2) www1 server saves file with permissions showing user "www" is the
owner, dir owner is the group for the file ("sg" in this case).
3) cron script on www1 scp's the file to www2 server.

All of this works great up until the following happens ...

4) User resubmits the file to www2 server
5) www2 attempts to update file located on www2 server with new
version, but cannot modify file (attempting to overwrite a file owned
by sg/sg with a file to be owned by www/sg).
6) User continues to see old image, new image is not replicated

PHP Class/library Zipping Client Computer Files And Upload To Server
Can anyone suggest good PHP class/library that can zip client local
files and upload to the server? Single package is great as well as
separate packages.

Copying File From Hosted Remote Sever To Local Machine
I am trying to use php to automate the copying of a file from my remotely
hosted directory to my computer. I have put together the following but it
will only do the copying from one directory to another on the remote server.
Reading the postings on these functions they suggest that it can be done but
it appears to be the case if your are hosting your site on the same machine
you want to copy the files to. Does anyone know if there are functions in
php to do the transfer from remote server to my machine or if the code below
will acheive this with modification?

<?php
$ftp_server = "xxxxxxxx";
$ftp_user = "xxxxxxx";
$ftp_pass = "xxxxxx";
$local_file = 'myfile.txt'
$server_file = 'myfile.txt'

// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to
$ftp_server");

$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);

// check connection
if ((!$conn_id) || (!$login_result)) {
die("FTP connection has failed !");
}

// try to change the directory to myfilesdirectory
if (ftp_chdir($conn_id, "myfilesdirectory")) {
echo "Current directory is now: " . ftp_pwd($conn_id) . "";
} else {
echo "Couldn't change directory";
}

if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
echo "Successfully written to $local_file";
} else {
echo "There was a problem";
}

// close the connection
ftp_close($conn_id);

Including Files In Different Direcories That Include Files From Teirs
Okay, I made a simple AJAX shoutbox and I want to include it on all my pages. To insert the shoutbox I simply type <? include('/shoutbox/shoutbox.php');?> into my HTML page.

The problem is, that in /shoutbox/shoutbox.php I also include settings.php, functions.php, and some other files, and when I include /shoutbox/shoutbox.php into my index page, /shoutbox/shoutbox.php tries to call settings.php from the same folder that my index file is in, since I just 'included' it in index's source.

So my question is, is there any way, without using frames, to include a PHP file as it would be if you link directly to it in the address bar, but placed into another file in a different directory?

How Do I Hide Database Connection Files Using PHP Include Files?
I have the following at the beginning of the PHP page:

<?php require_once('Connections/conn.php'); ?>

I want to hide the connection file, "conn.php", so it's out of the web
accessible file structure. I understand putting them in the php include
directory shoudl do this. For example, let's say the directory I put them
in is /www/phpIN/, and /www/ht/ is the root web directory.

So I put "conn.php" in the inlcude directory (/www/phpIN/conn.php) and
removed it form CONNECTIONS directory.

How Do I Hide Database Connection Files Using PHP Include Files?
I have the following at the beginning of the PHP page:

<?php require_once('Connections/conn.php'); ?>

I want to hide the connection file, "conn.php", so it's out of the web
accessible file structure. I understand putting them in the php include
directory shoudl do this. For example, let's say the directory I put them
in is /www/phpIN/, and /www/ht/ is the root web directory.

So I put "conn.php" in the inlcude directory (/www/phpIN/conn.php) and
removed it form CONNECTIONS directory.

Now it doesn't work.

What do I need to change?

Creating Dir, Copy Files And Pass Variables To 2 Files
I need to create a folder on the server weekly named by the user. To this folder copy the contents of an /Original folder. Inside the new folder edit one of the files to insert a data with a XML path generated in another application, copied (via memory) and pasted within the very first form and passed to the file in question.

<param name="FlashVars" value="xmlfile= $lanofile" />

the $lanofile is the value that I need to pass from the form to be read by this file.
I have created an form (n.php) that POST the name of the folder to a second file (creatdir.php) everything is cool until I have to edit the third file.

How can I pass the value of one of the formfileds to a second file and them read this value as a variable to be consumed as mentioned above? Or actually right whatever is on the third field to this position (not using variables).

Test Server To Live Server - Best Way Of Handling Different File Paths In Scripts?
I have taken over someone else's PHP code and am quite new to PHP. I made
some changes and have implemented them to a live environment fine so far.

However, I now want to setup a test environment. All the PHP scripts start
with a few lines of:

require_once "library file at specific location on server"

and when I move them from the test location to live location I have to
manually apply the changes to each script to reflect the different paths for
each server.

I was thinking of writing a small script that is contained within the same
folder as any folder that contains scripts that actually calls another
require for that server .

E.g.
Have script do_something.php which I am developing regularly.
On live server it starts with
require_once "/home/live/phplib/library.php";
On test server
require_once "/home/test/phplib/library.php";

Currently I apply a manual change this (via global change or whatever) when
moving from Test to Live
However, I might just change all requires to:
require_once "./require.php";

And then have a server specific version of require.php that contains the
necessary requires for the particular server on which it resides.

This way I can just change all the scripts to just require the require.php
file in the same folder as itself. The actual PHP scripts where I do most of
my updates need no changes whether on live or test servers.

I just wanted to know if there was a better way of doing it then this. I
know nothing about directives in PHP or if there was a way of determining
the current server name and then calling different require commands
appropriately.

SMTP Server - Sending Post From Php Script On Linux Server
Does any body know why send() is returning false..
where are the additional settings of SMTP server?

Code Output On Home Server Differs To Hosted Server
I just installed Apache, PHP and MySQL (all apears to work ok) on my WinXP machine at home. Apart from a few notice messages, the script mostly ran fine, except one of the forms. I simplifed it to a minimum, but it still doesn't work on my home server (tho it does on my hosted space). PHP Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved