f



how to copy files from ftp directory to web-accessible directory?

I need to copy files from an ftp directory to a web-accessible directory and 
then delete the files in the ftp directory.  (I am doing it this way because 
web-based form upload can not exceed 2MB and I can't change that)

Any ideas are much appreicated! 


0
lof (76)
11/21/2006 11:48:38 PM
comp.lang.php 32646 articles. 0 followers. Post Follow

2 Replies
467 Views

Similar Articles

[PageSpeed] 0

Paul wrote:
> I need to copy files from an ftp directory to a web-accessible directory and
> then delete the files in the ftp directory.  (I am doing it this way because
> web-based form upload can not exceed 2MB and I can't change that)
>
> Any ideas are much appreicated!

You can put a script like this on your webserver with the correct info,
then just run it in your browser. It will move the file.

<?php

$ftp_server = 'ftp.domain.com';
$ftp_user_name = 'ftpuser';
$ftp_user_pass = 'ftppass';
$server_file = '/ftppathtofile.ext';
$local_file = '/dirpathtofile.ext';

$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

if ((!$conn_id) || (!$login_result)) {
	echo "FTP connection has failed.\n";
	echo "Attempted to connect to $ftp_server for user $ftp_user_name.\n";
	exit;
} else {
	echo "Connected to $ftp_server.\n";
}

//DOWNLOAD
$download = ftp_get($conn_id, $local_file, $server_file, FTP_BINARY);
if ($download) {
	echo "Successfully written to $local_file\n";
} else {
	echo "There was a problem\n";
}

ftp_close($conn_id);

?>

0
pangea1013 (26)
11/22/2006 1:36:51 AM
thanks "pangea33" , I'll give it a try. 


0
lof (76)
11/22/2006 9:52:41 AM
Reply:

Similar Artilces:

files, directories, files, directories
Hi folks, I've been trying to make a decision and it's driving me crazy. Is a directory a file or is a directory NOT a file but a node? Should I have A) public interface IFile { IFileName FileName; IContent GetContent(); } public interface IDirectory extends IFile { } or B) public interface INode { INodeName NodeName; } public interface IFile extends INode { IContent GetContent(); } public interface IDirectory extends INode { } Method A is nice cause IFile becomes the base "Node" type and you can use names like "IFileName" which sounds nice compared to "INodeName" and fits with the "FileSystem" moniker. A has the disadvantage that IDirectory has a GetContent() method which isn't bad but can be considered a bit weird. It probably wouldn't be too hard to make users think of everything as a file. Method B is nice cause IDirectory doesn't have GetContent() -- that honour belongs only to IFile. B is at a disadvantage when it comes to naming: everything becomes a "Node". INodeName sounds rude compared to IFileName. This method feels more "pure" cause you're specialising features completely. Do you reckon I can get away with Method A? It doesn't seem as pure unless you spend a long time convincing yourself that (for all intents and purposes) a file *is* a node (it's just got a different name) and a directory *is* a file. A penny for anyone's thought...

List files from directory not in apache web directory
Hello everyone, is it possible to list files from directory other than in apache web directory? my web folder is placed on c:/ and i put my files in windows directory "d:/files/images/". I want those files to be able to view in client browser. when i tested using server computer it succeed. but from client computer i got nothing. I checked the html sources and the files is directly loaded from "d:/ files/images/file_name.jpg" and then i found out why computer client could not load that files. is there any other way to make it happened ? thank you guys for any kind of help. best regards. On Apr 4, 12:17 pm, froditus <frodi...@gmail.com> wrote: > Hello everyone, > > is it possible to list files from directory other than in apache web > directory? > my web folder is placed on c:/ and i put my files in windows directory > "d:/files/images/". > I want those files to be able to view in client browser. when i tested > using server computer it succeed. but from client computer i got > nothing. > I checked the html sources and the files is directly loaded from "d:/ > files/images/file_name.jpg" and then i found out why computer client > could not load that files. > > is there any other way to make it happened ? > > thank you guys for any kind of help. > > best regards. It will not be accessible from the client computer because apache cannot interpret the path. You should build a p...

directory/file copy over ftp
This is my first time working with the ftplib from Python. I am trying to copy files from the directory. Do you know how? ...

Accessing a file on a separate computer, not in the web directory
Probably an incredibly simple answer, but I can't seem to phrase it so a search engine can understand it. I have a php script with a simple include: include("/include_this.php") I need to edit this so it accesses the file from another server. I have tried: include("http://192.168.1.1/include_this.php:) But the file isn't in the web directory, which in this case is /usr/ local/apache/htdocs. It is one level above the web directory. I don't know how to reference /usr/local/apache/include_this.php on another linux server. I don't even know what the correct term or phrase would be for this. Any help will be greatly appreciated. On Mon, 13 Aug 2007 21:38:39 +0200, Jerim79 <mylek@hotmail.com> wrote: > Probably an incredibly simple answer, but I can't seem to phrase it so > a search engine can understand it. > > I have a php script with a simple include: > include("/include_this.php") > > I need to edit this so it accesses the file from another server. I > have tried: > include("http://192.168.1.1/include_this.php:) > > But the file isn't in the web directory, which in this case is /usr/ > local/apache/htdocs. It is one level above the web directory. I don't > know how to reference /usr/local/apache/include_this.php on another > linux server. I don't even know what the correct term or phrase would > be for this. Any help will be greatly appreciated. > (some of t...

Text Print Entire Directory Tree including File Names from a FTP Directory
Hello, I am looking for a way to get the ENTIRE (or at a given depth) directory tree of a FTP folder and files from an FTP server. The listing should include file sizes and modified dates, etc. as much info as possible through some configurable parameters. The same script may be able to be used on a local drive as well. I have managed to do this FTP directory task using the http://www.ftprush.com/ftp-directory-tree.html application. This application is pretty cool and it did exactly what I wanted. ********** My question is how can I do this using a Perl Script or any other free utility from...

Getting all directories/files from current directory and using -d flag for the directories
Hi guys/gals, I'm pretty new to Perl, so please keep that in mind. :) It looks like File::Find goes through all the subdirectories of the current directory, which isn't what I want. I just want all the contents of the current directory. On doing some research, many people have recommended doing something like the following: ----------- $home_dir = ''; #changed to protect the innocent :) opendir(DIR,$home_dir) or die "Can't open the current directory: $home_dir $!\n"; # read file/directory names in that directory into @names @names = readdir(DIR) or die "...

Via FTP, any way to copy a remote file to another remote directory
Hi, with FTP I'm trying to make a copy of an existing remote file in another remote directory, but I could find no way to do this. Some background: I'm trying to upload 50+ traffic webcam images into two different directories on my webcam server as QUICKLY as possible. One directory will be viewable at all times (e.g. for police etc). The other directory, we may close down to the public (in case of injury or bridge jumper etc). So in most cases I want to upload to the always viewable directory and make a copy to the other directory. Sure I can upload the file twice, but the se...

Delete a directory and all its files and sub-directories?
Hi, Does anyone know of, or have code that will delete a php directory and all its sub directories and files. "unlink" and "rmdir" don't do this. I'd prefer not to use "exec" with a system call but if that's the only way, so be it. I'm using PHP 4.4.4. Thanks, - Dave laredotornado@gmail.com said: > Does anyone know of, or have code that will delete a php directory and > all its sub directories and files. "unlink" and "rmdir" don't do this. > I'd prefer not to use "exec" with a system call but if that's the only > way, so be it. > > I'm using PHP 4.4.4. > http://ie.php.net/rmdir Read the first user comment on the page. The one with the function recursiveRemoveDirectory() D. -- ...

Script to move files with one occurence of a string to one directory, and other files to another directory?
I could use a script for the bash shell to look through a group of files (s= elected from one directory by a wildcard expression) and move any of those = files with exactly one occurrence of the string Path: to a different direct= ory, usually a subdirectory of the first directory. The rest of the files = selected by the wildcard expression are move to a third directory, also usu= ally a subdirectory of the first directory. I'm currently doing this manua= lly, but with grep commands to count the number of occurrences. NOT homework - I'm retired. Actually using Cygwin (an em...

Warning: Identity file ~/.ssh/id_rsa not accessible: No such file or directory
I install rwsync server on xp, and on fedora tried to ssh as follows; 1) on fedora ssh-keygen -P "" -f ~/.ssh/id_rsa chmod 700 ~/.ssh chmod 600 ~/.ssh/id_rsa ftp id_rsa.pub to xp 2) on xp append id_rsa.pub to /cwRsyncServer/var/SvcwRsync/.ssh/ authorized_keys2 3) and on fedora ssh -i ~/.ssh/id_rsa id@192.168.0.3 then I got this error message. "Warning: Identity file ~/.ssh/id_rsa not accessible: No such file or directory." My sshd_config on xp is as follows:: #Port 22 Protocol 2,1 #Protocol 2 #ListenAddress 0.0.0.0 #ListenAddress :: # HostKey for protocol version 1 #HostKey /etc/ssh/ssh_host_key #HostKeys for protocol version 2 HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_dsa_key HostKey /etc/ssh_host_rsa_key HostKey /etc/ssh_host_dsa_key # Lifetime and size of ephemeral version 1 server key #KeyRegenerationInterval 1h #ServerKeyBits 768 # Logging #obsoletes QuietMode and FascistLogging #SyslogFacility AUTH #LogLevel INFO # Authentication: #LoginGraceTime 2m # PermitRootLogin no # The following setting overrides permission checks on host key files # and directories. For security reasons set this to "yes" when running # NT/W2K, NTFS and CYGWIN=ntsec. StrictModes no RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys2 # For this to work you will also need host keys in /etc/ssh/ ssh_known_hosts #RhostsRSAAuthentication no # similar for protocol version 2 #HostbasedAuthentication ye...

Konqueror saves file .directory in every directory
Konqueror saves file called ".directory" in every directory where I change some view properties of this directory, e.g. when clicking the "Detailed view" icon. I can see this behaviour on only one my machine/account with KDE, while it is working fine elsewhere. How can I disable this nasty file creation? BTW, someone knows how to use a web search engine (google, yahoo, ...) to search for ".directory"? They always strip the leading "." and thus giving out millions of useless results. Thanks, P.M. Quoth Petr Mikulik : > Konqueror saves file called ".directory" in every directory where I > change some view properties of this directory, e.g. when clicking the > "Detailed view" icon. I can see this behaviour on only one my > machine/account with KDE, while it is working fine elsewhere. How can > I disable this nasty file creation? Don't change any nasty properties and you won't create this nasty file. > BTW, someone knows how to use a web search engine (google, yahoo, ...) > to search for ".directory"? They always strip the leading "." and thus > giving out millions of useless results. Did you mean to ask, "Does someone know how to use a web search engine?" The answer is... yes, someone does. It's just not you. For instance, I would never start a search for "dumb questions about my operating system GUI" with the lone term "dum...

Files, directories and imports
Hello, group. I can only read files and import modules that are in the same directory as the one my script is. Here is a test script (path.py): import os import uno # some module I wrote print list(os.walk('~/hacking/python')) f = open('~/read/foo.txt') print f.read() And here is the output: Traceback (most recent call last): File "path.py", line 2, in <module> import uno ImportError: No module named uno If I comment that import, the output becomes this: [] Traceback (most recent call last): File "path.py", line 4, in <modu...

Re: Finding directory file of current directory
From: "R Boyd" <bob@hax.com> > Here's a command procedure I wrote years ago to handle the issue: [...] > See if that solves your problem. It probably will unless it encounters a contrary ODS5 extended file name: ALP $ show default LDA1:[o5_test.TEST2.a^[b^]c] ALP $ @ [--]uponedir.com PREV_DIR_LEV = "LDA1:[o5_test.TEST2]" CUR_DIR_SPEC = "LDA1:[o5_test.TEST2]a^[b^c].DIR" ALP $ dir [-]a*.dir Directory LDA1:[o5_test.TEST2] a^[b^]c.DIR;1 Total of 1 file. Everything's complicated. (And getting more so all the time.) From: JONE...

restricting ftp access to directories
I am running RH 3.0ES with VSFTP. I want to restrict some users from leaving home directories or from browsing server directories. Other I only want to see a few directories. Here is what I have set up: Directory Structure (Permissions): /home/user1 (0755) /department/customers (2770) /department/distributors (2770) Users: User1 (home dir is /home/user1) Distributor (home is /department/distributors) Customer (home is /deaprtment/customers) Groups: Distributor Customer Users Here is what I want to accomplish: User1 can have full rights to his home directory and to th...

Copying a file into another directory
Hi What is the established way of copying a file/dir into another dir in Java? I was looking into 'java.io' package, but could only find a renameTo() method. It looks like it only renames the file or at the moves the same file to the destination dir. Please advice Thanks Sahil On 08-10-2010 08:03, Sahil Dave wrote: > What is the established way of copying a file/dir into another dir in > Java? > I was looking into 'java.io' package, but could only find a renameTo() > method. It looks like it only renames the file or at the moves the > same fi...

List of directories with a directory
I have a directory with 200 sub directories in it. How do I create a list of the sub directory names? I know how create a list of all the files in a directory: opendir(DIR, $dirname) or die "can't open $dirname: $!"; while (defined($file = readdir(DIR))) { next if($file =~ m/^\./); next if($file eq ""); push (@filenames, $file); } closedir(DIR); but how do I do it for the directories within a directory Al Moodie. On Tue, 29 Jan 2008 19:45:50 -0500, Al Moodie <nospam@nospam.com> wrote: >I have a directory with 200 sub directories in it. How do I create ...

directory access and file locations
Hello PHP group, I have a question about file locations, and whether on not (in my case, not) a page will execute depending on the location of the php file. I have a web devel server, with a directory below htdocs (using Apache 2.2 on Fedora Linux) /usr/local/apache2/htdocs/portfolios and /usr/local/apache2/htdocs/ portfolios/setup I thought it would be nice to put pages that involve moving files around, adding data to a mysql database, etc in a directory called "setup" I have another path /usr/local/ apache2/htdocs/portfolios/testimage that I read with my page, and copy data from the testimage dir into a database. I use code like below $path = 'testimage'; $dir_handle = @opendir($path) or die("Unable to open directory $path"); /*** Load an array with the list of files in the dir ***/ while ($file = readdir($dir_handle)) { //$filetyp =getFileType($file); no good for all images???OR $filetyp == 'gif' $filetyp = strtolower(substr($file, -3)); if ($filetyp == 'jpg' ) { $filecount++; //***$handle = fopen($path . "/" . $file,'r'); $filelist[$idx] = $path . "/" . $file; //add file to array //echo $filelist[$idx]; $idx++; //***$file_content = fread($handle,filesize($path . "/" . $file)); //***fclose($handle); } } closedir($dir_handle); I use the echo command to see if the files in the dir are being read, etc. this works when the php page is located in ..../portfolios...

copy file and directory with permission
i want to know any command or software for copy file and directory with permission to target location. thank you very much On Sat, 17 Apr 2004 00:54:28 +0800, happy wrote: > i want to know any command or software for copy file and directory with > permission to target location. cd /source/dir tar cf - . | (cd /target && tar xpf -) happy wrote: > i want to know any command or software for copy file and directory with > permission to target location. $ man cp -a, --archive same as -dpR -d same as --no-dereference --preserve=link -p same as --preserve=mode,ownership,timestamps --preserve[=ATTR_LIST] preserve the specified attributes (default: mode,owner- ship,timestamps), if possible additional attributes: links, all -R, -r, --recursive copy directories recursively ... So, it looks like you probably want $ cp -a source target -- Rex ...

What are the directories/files who php needs?
Hello, I have a chroot env, I have to copy all the directories/files that php needs to run. Could someone give me the list or information to know what dirs/files "import" on the chroot env ? Thank you! ...

protecting files and directories with php
Hello, I've got a situation where i have a directory called "example". In this area i have three files, an index page that has a form on it in to which user's can authenticate, a page displaying either success or failure and if success redirects to a downloadable file. I don't want this downloadable file to be had by a direct url access, user's should have to authenticate to get it. I want to use php4 for this and if possible since this is a lightweight requirement i don't want to implement a database solution. Any pointers or howtos appreciated. Thanks. Dave....

Module to copy files and directories
Hello, I�m looking for a comfortable Module to copy files and directories. The Modul should (very!!) be fast. thanks, Jochen Jochen Friedmann wrote: > Hello, > > I�m looking for a comfortable Module to copy files and directories. > The Modul should (very!!) be fast. > > thanks, > > Jochen A quick and dirty fix would be system() and "cp". Of course, it isn't a module; but then that may be an adavantage. Cheers pete "Janek Schleicher" <bigj@kamelfreund.de> wrote in message news:<pan.2003.08.05.15.52.55.731001@kamelfreund.de...

copy files from multiple directories
Hi, I want to copy txt-files only from multiple directories. All the directories (Run 1 ~l Run N) are sub dir's of a dir called DATA, e.g: -> Run 1: bla.txt, ready.xls, clear.doc DATA -> Run 2: esp.txt, fey.txt, show.xls -> Run N: ... So, I just want to copy bla.txt, esp.txt and fey.txt to 1 directory, let's say C:\test\ How can I fix this in matlab? "@ddie ertser" <ivogrunn@hotmail.com> wrote in message <hpd0ce$f57$1@fred.mathworks.com>... > Hi, > > I want to copy txt-files only from multiple directories....

copying multiple files and directories
Hi, I have my music sorted in folders as below. C:\Users\Me\MyMusic\Band1\Album1\ Some of the folders contain music in mp3, some wma. I want to copy all the directories containing mp3 files and the contents of those directories to another drive. I can list all the files using dir /S *.mp3, but I can't find an obvious way to move all the files in one go.... Any help would be appreciated... Rich richdyer_2000 wrote: > Hi, > > I have my music sorted in folders as below. > > C:\Users\Me\MyMusic\Band1\Album1\ > > Some of the folders contain ...

SQL1326N : file or directory cannot be accessed
Hello, using 10g I'm trying to create a database in the instance 'bruno' but receive error code : SQL1326N The file or directory "/home/bruno/" cannot be accessed Platform is Linux and I tried : chmod 777 /home/bruno chmod -R 777 /home/bruno/sqllib/ but without success. Thanks for any clue. Bye, Bruno Bruno Costacurta wrote: > Hello, > > using 10g I'm trying to create a database in the instance 'bruno' but > receive error code : > > SQL1326N The file or directory "/home/bruno/" cannot be accessed > > Platform is Linux and I tried : > chmod 777 /home/bruno > chmod -R 777 /home/bruno/sqllib/ > > but without success. > Thanks for any clue. Usually you create a unix user to own the oracle software and executables ( often the unix user created is "oracle" ) and then some groups such as oinstall and dba. Did you do that? Do an ll ( or ls -la perhaps on linux ) on the oracle executable ... what does it look like? Typically you create datatabases in different directories than /home .... such as /u02/oradata etc. On Sun, 08 Oct 2006 16:39:13 -0700, hpuxrac wrote: > Usually you create a unix user to own the oracle software and > executables ( often the unix user created is "oracle" ) and then some > groups such as oinstall and dba. One usually starts by reading documentation available on the internet. When doing that, one must have in mind that internet is ...

Web resources about - how to copy files from ftp directory to web-accessible directory? - comp.lang.php

W3C, others seek accessible Web
There are 54 million people in the United States with disabilities, so it's no surprise that better access to Web sites is a goal being sought ...

Skip the Lists for a More Accessible Web
Long ago it was decided that website menus shall be marked up with HTML list elements. But that was long ago; now we have the new elements in ...

Microsoft Corporation Skype For Web Now Widely Accessible In US And UK
... (NASDAQ:MSFT) Skype beta version has been made available to users in US and UK, allowing Skype calls and instant messaging through a web-browser ...

Make your website more accessible to more users with Introduction to Web Accessibility
By Eve Andersson, Manager, Accessibility Engineering You work hard to build clean, intuitive websites. Traffic is high and still climbing, and ...

WhatsApp Is Now Accessible On The Web, But iPhone Users Are Out Of Luck
WhatsApp has finally arrived on the web, but unfortunately not everyone will be able to use the service. WhatsApp Web , which promises to "mirror ...

Flipboard Is Now Accessible On The Web
... out on the iPad three years ago as the first tablet-only personal magazine. This application aggregated news feeds from across the web and turned ...

Design Management Systems Make Web Design Accessible
Content management systems (CMS) have changed everything about how we maintain websites. Thanks to modular drag-and-drop options on CMS setups ...

Cryptocat Makes Web Privacy Easy and Accessible
Nadim Kobeissi has made encrypted online communication sexy

Around the Web: Universities have been taken over by administrators, Scholars should make their ideas ...
Universities have been taken over by administrators Making Our Ideas More Accessible (by blogging, twitter, etc) University Of Toronto's Lawyer ...

Web Development Reading List #118: Opera Mini, BPG Format, Accessible Tabs and Flexbox
What’s going on in the industry? What new techniques have emerged recently? What insights, tools, tips and tricks is the web design community ...

Resources last updated: 3/23/2016 9:30:43 PM