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?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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.
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);
Server To Server File Transefer Script, Getting Wrong File Size
Any help on this is most appreciated. I have created a function to download a file. It seems to work except the file sizes differ greatly. I start off downloading a 5mb .zip file and end up with a 2mb .zip file on the initiating host. Thanks for any advice on this. function get_http_file ($host_url, $http_file) { global $host_url, $http_file; $fp = fopen("$host_url/$http_file","rb"); while(!feof($fp)) { $my_file .= fgets($fp, 4096); } $fptmp = fopen("/tmp/$http_file","wb"); fputs($fptmp,$my_file); fclose($fp); fclose($fptmp); if (file_exists("/tmp/$http_file")) { $result_code = 1; } else { $result_code = 0; } return $result_code;
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.
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.
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.
Doing A Server To Server File Transfer
I have two server. I am trying to copy all the files from one to the other. The problem is that there is 80gig to be copied - so I would like to send it from server to server without downloading and the uploading it again. Is there some way I can use ftp or mget or get or wget or something to move the files faster?
Copying Remote Files
How do i copy a picture or another file from a remote webpage, and put it into my webpage dir?
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.
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 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:
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:
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.
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?
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:
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?
Email With File Attachements - How To Upload File To Server From Browser?
I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. I want to develop a webpage where people can send attachments that are stored on their local PC. I know I can use the <input type="file" > HTML to generate a file box that allows the user to navigate to a file on their PC and product a file path, but how do I then upload this file onto file server to email out with my PHP email script? Is there an easy way to do this? Or can I approach this problem from a completely different angle.
Script For Grabbing An Xml Rss Feed File Into My Server As Xml File Too
How do I copy using a php or cgi script a remote xml rss feed into my server? I.E the rss feed: http://www.lanacion.com.ar/herramie...ex.asp?origen=2 Due to restrictions in flash player 7 I need to load a remote xml rss feed. I am using load.xml( http://www.... but in that way doesn´t work The only way that works is when the rss xml feed is placed on my server. I could upload manually the xml rss feed but I need a php script to be called from flash and then parsed. What I need is the script to make that remote xml being "local" to my flash movie. Trying other stuff Ive found on forums about "proxy scripting" but that only works if you are using flash player 6, flash player 7 even don´t allow redirection scripts at all.
Deleting A File From Server Through A File List
I've been having trouble with this for a while. Ages ago I made an upload script that lets you upload to files/upload/ and then once you upload it, a piece of PHP will show the files in that folder. In the admin section of my page i'm trying to find a way to delete the files off the server without having to dig into the FTP and do it manually. Are you able to do that with PHP? Code:
Multiple File Upload From Client Pc To Server Without Using <input Type="file"> Cont
I am working on a application which requires me to upload the contents of all the files from a particular folder in clent pc to the server. In my code i just want to mention the folder name which may contain any number of files.Folder name will always be fixed. I dont want to use <input type=file > control. Is there any way i can achieve this using FTP or any other way in PHP.Any help will be greatly appreciated.
Try To Get A File From A Server By PHP
I am trying to make afunction to get information from one file and print it or put it in an array, the problem in headers I can't figure that it is giving me this: ******** HTTP/1.1 400 Bad Request Date: Fri, 21 Oct 2005 14:48:06 GMT Server: Apache Connection: close Content-Type: text/html; charset=iso-8859-1 Bad Request Your browser sent a request that this server could not understand. Request header field is missing colon separator. Host=www.imtec.ba ******** My code is : ********* <? function getFile($host,$file) { $request="GET $file HTTP/1.0 "; // This is the path part of the link $request.="Host=$host "; // This is the server part of the link // Now let's try connecting: $fp=fsockopen($host, 80, $errno, $errstr, 30); // Let's see if we made it if (!$fp) { return(false); } else { // If we made it, let's send the request: fputs($fp, $request); while (!feof($fp)) { $response.=fgets($fp, 128); } fclose($fp); return($response); } } echo getFile("www.imtec.ba","index.php"); ?> *********
Upload File Into Server.
I want to upload image from browser to server. Exp: Your customer can upload new product in our website. What can I do?
Server File System
usually with cgi scripts they are kept outside of the htdocs directory for security and are in a directory with only executable permissions. how does php relate to this? - where should they be stored and with what permissions? could someone please point me to some good online material covering these issues.
Copy A File To The Server
is it possible to copy a certain given file from a set location to the server everytime the page is accessed? I have to build a site wehere daily new information has to uploaded to an intranet server, like new exchange rates. therefore i want to build a script that automaticaly uploads a csv-file to the server whenever it is accessed. the file that has to uploaded resides(and is updated) an a certain machine on the lan. is this possible? and how would you do it? PHP Code:
Accessing A File In Another Web Server
I am trying to determine if a file exist in a another web server and if it does exist then I will display the link of the file. I tried is_readable(), file_exists() and stat() and they both say that the file does not exist, but the file does exist. What function should I use to check for existance of a file on a different web server?
Saving A File From One Server To Another
I'm half-way there with this, but I need some assistance, please. I'm attempting to save a JPG file from one server to another. I'm using fopen() to open the remote file, fread to get the contents, closing, using fwrite(rb) to open a new file on my server, writing the contents, and closing. However, it seems that I'm not getting the entire file from the remote server. Am I going about this wrong? Is there a better, easier way (that doesn't involve CURL or any of those other acronyms) to get these images?
Getting File Names On Another Server With PHP
My ISP provides me with minimal space on a dedicated server running PHP, and 250MB on a separate HTTP server. I'm trying to make a gallery using PHP. The script is held on the PHP server, and the thumbnails and images are on the separate HTTP server. Ideally I'd like to be able to get a listing of the contents of the HTTP server where the images are stored. I want to do this so that when I add/delete/change images, the dynamic nature of the site just picks up the new files and I don't have to maintain a separate database of the image names and where they're stored.
NS 6 Linking To The File And Not The Server?
I have a link looking like this: <a href="<?php $_ENV["SERVER_NAME"]; ?>">LINK</a> With IE it works fine, but in NS the link is servername/file_where_the_link_is.php How do I fix that?
Including A .php File From Another Server?
I am trying to include a function in a .php file on a different server from the main .php files. I am using: include_path=http://www.anotherserver.com/foldername; include(http://www.anotherserver.com/folder...iletocall.inc); The .inc file is php formatted. Variables are passed to it (not via GET or POST though) and returned using return(variablenames, etc); But for some reason it doesn't appear to work properly. Am I correct in using the .inc extension? Are the commands above correctly written? Basically I am trying to use the fsockopen function in a .php file on another server where I know it works and return the results to a server where the fsockopen command doesn't work.
Ftp Always Puts 1kb File On Server
this script used to upload files to the server without any issue: $oFTPConn = ftp_connect($sFtpServer,21,600) or die("Unable to connect ot $sFTPServer!"); //login to the ftp server and upload the file // $iFtpTimeOut = ftp_set_option($oFTPConn, FTP_TIMEOUT_SEC, 600); $cmdLogin = ftp_login($oFTPConn, $sFtpUserName, $sFtpPassWord) or die("Unable to connect to login to the FTP server: $sFTPServer!"); $cmdUpload = ftp_put($oFTPConn, $sFullDestinationPath, $_POST['srcFile'], FTP_BINARY); if ($cmdUpload != FTP_FINISHED){ echo("There was an error uploading the file..."); } $cmdCloseFTP = ftp_close($oFTPConn);
Copy File From One Server To Another
How can I copy a file(s) from my server to another server? I trying to keep files on a develpment server current with a production servers files. So if i have files "a", "b", "c" on the production server, and files "b", "c" on the develpment server, i want to copy "a" from the production server. Is this possible? Also is it possible to upload a file to several destinations?
Write A File To Another Server
how to write a file to another server. I can write a file to the server it is on, but what happens is that it is a shred server so when people upload stuff using microsoft frontpage they change the permissions which crashes my scripts, so i need to write to a nother server. I have tried scripts (always do before bugging you guys) but i have no luck.
Rename A File On My Server
say i upload a file through FTP... and its called John.jpg how will i change it using php .. using a form to change it to Jay.jpg for example?
Creating A File On My Server...
I need to find out what I would to to create a file on my server from a personal form. Like lets say the form is like this: IdNumber: 7 Username: Drags111 Password: Password I would want the name of the file to be the idnumber (7 in this case), and the contents to be like: Username: Drags111 Password: Password Also is it possible to password protect the file when I make it?
Download File To Server
I have been trying to find out how to get a PHP script to download a file from another server (via HTTP not FTP) and save it to the server that is running the PHP script. I have been able to find out how to upload a file from say my computer and how to download a file from the server to my computer but not from one server to another. I was wondering whether anyone has any ideas on how I would be able to do this or somewhere which has information which would help me to figure this out
Editting A Txt File On My Server...
I have a login form with username and password (html of course). When you hit submit, I want the php script i have to make a log of that login. Heres what I got for the html part: <form action="login.php" method="post"> Username: <input type="text" name="usr" /> Password: <input type="password" name="pass" /> <input type="submit" /> </form> I want the php's name to be login.php, and the text file's name is loginlog.txt.
Upload File To Other Server
I have 2 Servers running. 1 for images, 1 for php docs. I have an image upload script.. both servers are under the same domain ie. http://www1.mydomain.com http://www2.mydomain.com Is there anyway to resize my images etc on the php server and then directly upload the files to the other server without having to ftp it and then delete it from the php server?
Uploading A File To Another Server
I currently have 1 server on a local network hosting a site but the net connection can no longer take keep up with the bandwidth. I was thinking of making a mirror of my site and push all of the large files to the second server thats at another company. Therefore i'd have www1.mysite.com which has our databases etc and core files. and www2.mysite.com would store all the images, videos etc. The problem is that the uploads need to happen on my server because I have a bunch of patches on my PHP that the other hosts dont that my upload scripts require to show the amount of a file uploaded etc. Is there a way to upload directly to another server? Or is it possible to upload to server 1, then automatically ftp it to server 2, then delete from server 1?
|