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);
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Printing To Local Machine For The A Remote Site
I would like to find out if I can get a page to print on a printer physically next to the server when a user of my site clicks the submit button. I'm sure that there's a way, but being new and slightly slow I'm not sure where to even begin looking.
Local Apache Server Error, But Ok When Hosted
I have just used a script that includes the first line session_start(); On my computer where I have apache php and mysql installed I get the error: Warning: session_start(): open(/tmpsess_4e8a9cf51a21ab1c9fe26630d5446262, O_RDWR) failed: No such file or directory (2) in c:serverapachehtdocsmaindex.php on line 2 But when I upload it to my host the page works without errors. Is there a problem with my apache setup or is it a php thing?
Copying Remote Files
How do i copy a picture or another file from a remote webpage, and put it into my webpage dir?
PHP On Local Machine
Back in 2004 I installed PHP, Apache and MySQL on my local machine to do some testing. I have not used it since. I just tried to browse one of my .php test files in IE and it opened up in Dreamweaver! Everything seems to be in place where I left it, I restarted Apache just in case - but no joy. Is there something simple that I have forgotten to do? - something I should have started up? - or something I can check? I would like to avoid reinstalling the software if possible as I recall having a few "teething problems."
PHP Copy To Local Machine?
I am building a small page to copy files from our server(s) to our users local machines. It's very simple... (below, "f" is a mapped network drive) <?php $source_file = 'f:somefile.whatever' $destination_path = (I want to move it to the USERS C:somedirectorysomefile); copy($source_file, $destination_path); ?>
Accessing Mail On Local Machine
This is probbly not a php question but here goes: I recently installed cyrus-imapd. The imap server is up and running, I am able to login but it says that I have no mail but if i use pine I am able to see all my messages.
$_FILES From The Server - Not Local Machine
I'm just playing with someone else's code and was wondering how to get details of a file that's already uploaded to my server into the $_FILES super global. the code I have is: ...$uploadedFileName = $_FILES['filename']['name']; if($_FILES['filename']['size'] > $maxSize) {... all the checks are done using this and I just want to parse all this info without the user having any control / knowledge of it at all. It's for an image upload script which has been built already, but I want lots of differing quality thumbnails to be generated, but the current code keeps asking the user to input size variables and path details to upload a file from their local machine.
Test CRON On Local Machine (WAMP)
How could I test-run a CRON on a local machine? Com-line or Putty does not find local host or 127.0.0.1 I never tried that before so I am clue less! don't even know if it is possible? How can I manage it on a local machine/localhost run by a WAMP
Remote Machine Access
I have to access the remote machines of the intranet of my organization. All the system information regarding free memory available and what operating system they have n all such system level details.
Running Batch Script On Remote Machine
I have a windows batch script that I've hosted on an FTP site (ftp://ftp.domainname.com/folder/script.bat). I have a link to it on a webpage. When a visitor clicks on the link the browser gives him the option to save or to run the file. If the user wants to save the file and look at it afterwards, he can. I do not want this to be possible. Is there a way to have the browser directly run the script on the visitor's PC while only giving him the option to run or not (just ask him for his consent) using PHP programming?
Can't Read Remote Web Page From Local Apache/PHP
I'm trying to read the contents of any Web page on another host. I'm finding that... echo file_get_contents( 'http://www.php.net' ); .... works fine if I upload the PHP script to my Web host, and run it there. But if I run it on my PC, which is running Apache 1.3.33 (Win32) and PHP 5.0.5, then it always times out, and gives me the error message... [error] PHP Warning: file_get_contents(http://www.php.net) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. I get the exact same results using... $fh = fopen( 'http://www.php.net', 'r' ) or die( $php_errormsg ); while (! feof($fh)) { $page .= fread($fh,1048576); } fclose($fh); echo $page; Anyone know what could cause this to happen?
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?
Redirect Page On Remote Web Host When Local Server Is Offline
Hope some one can help . I have my web site hosted on powweb (my remote web host)and I want a user to be redirected when they access my local server through a link on my remote web site to another page on my remote web site when my local server is offline.
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?
Php MySQL Works On Remote Server, Only Partially On Local Server
code to populate form select fields with data from a MySQL database, so a user can use those to sort/filter and view the 3,000 records. No inserts -- just selects; very simple. I originally set this up using URL-based query strings at http://stjuliana.org/school/ar/BUindex.php but since that only allowed sorting and not filtering, hence all 3k records load, I made a form verson at http://stjuliana.org/school/ar/index.php . Everything works just fine, however, there's still a lot of tweaking I want to do, such as splitting the form input and output into two pages (_blank), having a printable version, etc. To that end I just set up the latest builds of Apache, php and MySQL on my local Windows XP box, lest I blow my beer budget for the month on bandwidth overage. <g> I have a very simple page I used to test my localhost setup and everything's fine. I can connect to MySQL, create, insert and select from DBs, so I know my config is fine. All my other .php pages on this site work fine locally as well. The two abovementioned pages, however, are giving me fits when run locally... For the URL-query-string version, it loads up with the default view (=name_ns), which grabs all records and sorts by name and point asc. No matter which of the other sort 'views' I might choose, it still loads up all the records in that default sort. The server's holding on to something and I don't know how to clear it. The remote version correctly sorts based on the query string chosen. The form version is worse. It connects to the DB and populates the select boxes with the field data -- that part's fine. But no matter which submit button is selected, no data is retrieved. I get no error, but no data either. The form's action is set to $_SERVER['PHP_SELF'] and I've tried both GET and POST -- no change. Since the exact same pages work on the remote server I know it has to be something on the local setup. But where do I look if there's no obvious error? This is probably something incredibly basic but I'm bleary-eyed from reading tutorials and forums all over the Internet and can't come up with anything.
PHP On A MacOS Sever. Where Is Php.ini?
I have a client who is using a Mac OSX server. I'm logged in now, but I cannot find php.ini. Is the file called something different on a Mac? I need to locate the variable for max_uploads and increase the size.
PHP Uploads - Internal Sever Error Page
I have created a script to uploads files for my site; however. When I upload a test to my folder /php_uploads/ the file is transfered but then I will receive an Internal Sever Error page. I did create a thank you page so why should I be receiving this error? Again, the file is in the folder, but I will get the error.
Posting Local File Info To A Php File!
I have a script that I run locally and im trying to get the info to post to a php file so that I can view it in a browser. What I need to know is how to set up the receiving php to post it to the .html . Now I thought it went along the line of creating the php file and putting it on the root of the server then running the local script against a that php info file and it would dump the info to a browser but it wont work like that (I'm guessing cause it's a local script and not on the web) I know this line is sending it to the .php in that directory but I don't know how to set up the receiving php I guess is my problem. gosub phpsend www.xxxxxxxxxxxxx.com /xxxxx/xxxxxxxxx.php %sendstring I guess what I need to know is whats the best way to post the received data to a browser after the script runs. Or to set up the receiving php file as for outputting it I can create the page I just need to know how to receive it .
PEAR Modules On A Hosted Server?
Is there any way to utilize PEAR, Specifically PEAR DB on a host (shared server) where I cannot install PEAR. I spent some time reading the Install documentation and my brain is numb, without drawing any conclusions. My host has a /php directory at the root, which appears to be a member of the include path. I have an object that requires PEAR DB and I do not think I can rewrite the DB calls in a reasonable amount of time.
Writing To A Local File
We have a PHP/MySQL database application. A user would like to be able to run a routine to read selected data from the database and export a flat file to their local C: drive. After reviewing the documentation and posts, it is not clear how to do this, or even if it is allowed by the browser. If someone could point us in the right direction, we would greatly appreciate it. The application is hosted on a Linux server. The users are required to use Internet Explorer running on Windows 2000 or XP (we also use VBScript).
Can I Launch A Local .bat File With PHP?
I need to write small web app that can launch a few .bat files from a local machine. Is this possible with PHP, or would javascript be a better option? All i need to do is select the file (some HTML) then have a button to execute.
Reading Local File Not On Server
I am trying to parse a file which is located on the users local drive and then take this data and put it into the mySQL DB. However, I get errors when I pass in a file path such as C:Documents and SettingsAdministratorDesktopfooSLInfo.txt.
Read File On Local Drive
lets assume that the sysadmin granted to read those files, what php functions needed? can u give me ur ideas how to do it?
How To Process A Local File Rather Than Just Read It
I can read a local file with fopen("myFile.php"); However this gives me the source of the file (i.e. php code). I want to get the results of the file after it has been evaluated (i.e. HTML). The obvious way of doing this is include 'myfile.php' However, I want to process the evaluated result. For example: echo htmlentities( include 'myfile.php' ); This doesn't work because the result of the include statement is true or false rather than a string. I'm sure this is very simple, but I'm just learning.
Mysql_connect Error Apache Web Server To Windows Hosted Database
I've got MySQL 5.0.21 running on Windows Server 2003, and php running on Apache on a Linux box (Fedora Core 4). Previously when the pages were running on an IIS server the connection was succesful, now I get: Can't connect to MySQL server on 'SERVER' (13) I'm connecting using: $db = mysql_connect("SERVER", "USER", "PASSWORD") or die("Could not connect to database: ".mysql_error()); mysql_select_db("DATABASE", $db) or die("Could not select database: ".mysql_error()); However from the linux box I can connect no problems using: mysql --host=SERVER -u USER -p
Writing A Local XML File From A Parsed URL? Similar To RSS
I am trying to pull the XML data from the following stream: http://......and write it to a local file. Actually, what I would like to do is take the above stream and display it into a website... much like displaying RSS feeds on a webpage. I looked at javascript, but someone there pointed me to the PHP group. I may not have worded the subject correctly.
Copy Large XML Output To A Local File
I have a URL that when called generate a very heavy XML Feed like: www.domain.com/generateXML.php?id=products when i call this URL in the browser i can see a very long XML file generated containing different information..i want to copy this all output to a local file on my server so that i can use that file's info for different tasks on my site...PHP Code:
PHP-generated Link To Local File Doesn't Work When Clicked On. Why?
I'm running an Apache server on my own computer (Windows XP Pro). I wrote a simple PHP script (called test3.php) that I'm running by putting the following URL in the address bar of the browser (Firefox) .... http://localhost/test3.php The script generates the following link using the echo statement ... <a href="file:///C:/pictures/xyz.jpg"> Picture </a> ("C:/pictures/xyz.jpg", as you can guess by now, is an image file on my harddrive, but it's not in the document root). When I clicked on the link, nothing happened. However, if I RIGHT-click on it and select "Copy link location" (which copies the URL to the clipboard) and then paste the URL into the address bar of the browser, the picture then displays correctly. Why did it not work when I clicked on the link the first time, but it only worked when I pasted the link to the address bar? Is there some special notation/syntax that I need to use to get this to work properly?
How To Populate HTML Table From Local Text File.
I am looking for a way to populate an HTML table from an external local text file which looks like this: DATE/TIME LAT. LON. DEPTH. ML. -------------------- ---------- ---------- ------- ------- 21/03/2005-04:06:03 XX,XX XX,XX 171 3,42 21/03/2005-12:23:53 XX,XX XX,XX 500 5,4 21/03/2005-12:43:10 XX,XX XX,XX 553 5,38 21/03/2005-18:47:51 XX,XX XX,XX 162 3,91 21/03/2005-19:29:49 XX,XX XX,XX 500 3,51 21/03/2005-20:04:51 XX,XX X,X 75 3,72 The file could have more rows (DATA) that I show here. The file is provided to me on a daily basis and I have to update a web page daily with the contents of the file. I considered using JavaScript embedded in the HTML page but I am a newbie on what scripting for the web it refers. How can I populate the HTML table with this text file which changes everyday. Also, is it possible to use php client-side only, without a server?
Filesize Of Remote File
I did a search for this and found information, but couldn't make any sense of it. How would I find the size of a binary file on another server?
Remote File Transfer
hi, ive been messing around with uploaders and the like, how can i use an uploader to transfer a file from server to my server ? via a http://www. connection ? my reason for this is that i am on 56k, and there would be no sense in me downloading from a website and uploading to my website, especially using huge files.
Accesing A Remote File
I would like to now if it is possible to acces a file from another computer throw LAN. Do be more prcise I want to know if it's possible using netBios not http or ftp.
How To Invoke Remote Php File From Php?
I have a local php file and I need to get info back from php file on the server. How do I invoke remote a php? I can access this remote php thru a simple url and it prints some info on the web page. How do I get this info back to store as a variable in local php?
How Can I Tell If A Remote File Is An Image
I've written a link aliasing script that allows users to rewrite urls on their web pages. The crux of the script is the following: if(getimagesize($redirect_to) == 0) header("Location: $redirect_to"); else include("$redirect_to"); Which uses getimagesize() to determine if the link specified in $redirect_to points to an image (i.e img src) in which case it should include the image in the page, or if the link points to another website (i.e. a href), in which case I use the header method to redirect to that page when the link alias is called. So far this script has been working great, but I recently had a customer run it under php4.2.2 and the getimagesize is taking approx. 160 seconds to execute. Can anyone think of a different way to tell if a remote file is an image? And also, has anyone else experienced this kind of behavior with getimagesize when running php4.2.2?
Get A Remote File Size
Can I find a remote's file size without reading it all (this is an http connection not ftp)
Best Way To Display A Remote File?
I actually use readfile(http://www.anotherofmydomain.com/file.php); but I was wondering if it is the best way to do this or there is a better or a faster way since my files are pretty big.
Remote File Edit
i want to edit my index.php by www i print file in 'textarea': <textarea cols="95%" rows="20" name="text"> <?php readfile("../index.php"); ?> </textarea> how can i save contents after editing it (editing in this textarea)?
Getting Data From A Remote File
I'm trying to create a script that will download html data from another page, extract the exact data I need and cat some data to it, then print it all. Here is what I got so far: Code:
Checking Remote File When Server Is Down
My webpage displays images from a remote server and occasionally the remote server goes down. I want my PHP page to check if the remote images are available and if not, take them from another source. I tried this code: $mirrorpath1 = "http://sevtrek.vinyamar.com/archives/p1.gif"; if (@fopen($mirrorpath1, "r")) { echo "File exists"; } else { echo "File does not exist"; } Normally this code works fine. Eg - if the remote server is working okay but the file doesn't exist, no problems. But if the remote server is down, this PHP script just sits doing nothing. It never gives either option - file exists or file does not exist. Is there another way to check if a remote server is unavailable?
Writing To File On Remote Server
Is it possible to open and write to a file on a remote server by using the command fopen("http://www.myserver.com/myfolder/file.jpg", "w") ? If I try this, fopen does not return a file pointer (Even if /myfolder is "wide open", chmod 777).
Get File Size From Remote Server
I would like to know if anyone knows how to get the size of a file located on a remote server. I am almost 100% sure it can be done. I'm just not sure how. If anyone does know how, size in MB rounded to the nearest 2 decimals would be my preferance.
CAN I Include A Remote File In My Filesystem ?
Hello, I did a rough search on the web on how to include remote files. But most of what I found was inappropriate. Anyway ... What I want to do is create a configuration file wich will have all the DB connection settings and other sensitive information (config.inc.php) and be a able to access it within the server AND from a remote server... (e.g. I want have all the website settings in my machine but the website is hosted elsewhere) or I want to restrict access of my confiuration file from the hosting company. There are two cases that I am looking at.... : 1. The config.inc.php file is located in another webserver and can be accessed from the www.domain.com/configuration 2. The config.inc.php is located outside the web accessible folder (and that is the most preferable way of doing it) e.g /home/config_includes/ I would appreciate if you can give me examples of how and If I can do that....
Writing To A File On A Remote Server Without FTP
I am new to PHP and have a small problem and wondered if anyone could help. We have three sign-up areas for our site, two are hosted on our server, a third on another site for very good reasons. I want a logfile of when people subscribe. The logfile is hosted on our server. Writing to the logfile is easy for the two scripts running on our server. My original plan for the remote site had simply been to open an FTP connection and write it that way, and that worked a treat - until I got the remote site to test it on their servers. They do not allow outbound FTP. This may be the world's stupidest question, but is there another way of passing the results of the sign up (which is just a date, an email address and to which list they have subscribed) to the logfile on our server without using FTP? Is there someway I could use $_POST for example?
Remote File Blocked With Fopen?
For some reason, google doesn't let me open up it's search query with fopen? Is there an alternate way to get it that I am unaware of? Code:
|