Recursive Copy Of Folder/files
I want to copy entire content(have both files and folders)from One folder to destination folder..
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Copy Folder?
I want to copy a folder, subfolder, files, and subfiles. I don't care about attributes. I thought about making the folder a zip, and then using extract but that was confusing and took too long on the server. so what do I do? Is there a script that will parse the dir and COPY all the files?
Copy Entire Contents Of A Folder To Another
Situation: I am creating a folder based on input from a form and then creating an images folder underneath that -- that works great and I can read and write to the newly created folders AS LONG AS IT IS ONE FILE AT A TIME!!! What I would like to do: I would like to copy the contents of an entire folder over to one of the newly created folders ALL AT ONCE -- or in a loop -- which is what I am trying to do but keep getting denied. My code as it is now: if ($handle = opendir("$sourcedir")) { echo "Directory handle: $handle<br><br>"; echo "Files:<br><br>"; while (false !== ($files = readdir($handle))) { if ($files != "." && $files != "..") { if (!copy($files, $imagepath)) { echo "failed to copy $files into $imagepath<br><br>"; } } } closedir($handle); } all of the variables are working fine... it goes through the loop just fine -- I know this because it prints out the error for every file in the folder... it just won't copy the files over to the new folder while in this loop. Here is the beginning of the error messages: Directory handle: Resource id #2 Files: failed to copy step_c1.gif into /htdocs/www/schemes/adfasa/images failed to copy step_b1.gif into /htdocs/www/schemes/adfasa/images failed to copy step_a1.gif into /htdocs/www/schemes/adfasa/images by the way: adfasa is the folder name brought in by the form and images is the folder I create underneath it. Is this something that is possible to do in a loop? If so, what is wrong with this one. If not, how is something like this done? Of course since I know the files that are in the folder I want to copy from I could just go ahead and copy them ONE by ONE but that doesn't seem to be very efficient.
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).
Copy Files To A Different Dir?
I have a file which is located in "/usr/home/coreyr/html_files" and I want to copy it to "/usr/home/public/html" I've tried the following and I receive errors. <?php copy('sf.html', '/usr/home/public/html'); ?> any ideas?
Copy Files From Remote URL
how can I copy a file from a url into the directory where my php file is located? On the server I use it is not possible to use the copy() function for this task.
Copy Files And Folders
Assuming you had a template folder and files on the webspace and you wanted to make a exact copy/rename of it with a username and password being the one and only difference - how would one do it ? . (the difference being a password protected folder)
Copy Files And Folders From One Directory Into Another
I have files in myurl.com/myfolder and I would like to copy all of them into myurl.com/newfolder I'd like to copy all of the subdirectories and files that are in /myfolder and I would like to be able to use a form of some sort to name the file I want to copy, and create the folder I'd like to copy it to, such as newfolder. How can I use a form to create a new folder on the server? How can I use a form to name the old folder I want to copy everything from, then create the name of the new folder I want to copy everything into, and then copy?
Paging Of Folder Files
i have a form which has a select button when user clicks it a popup opens which shows all images in abc folder when user clicks on any image the window closes and the name of that image is entered in the text box in parent form, now its working fine uptill here but if user refresh the popup window then it disconnects from parent window so my code that fills the textbox in the parent form and closes the popup window does not work anymore im using it like parent.document.form.texthox.value=abc since popup window is refreshed it does not work as child any more and this code does not work.
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
What Is The Max PDF Files Allowed In A Folder?
Not sure where to put this question? I am building a book archives database with a front-end for some librarians. They want to upload book cover images onto the server (probably Win-NT). There are approximately 80000 records that will have the book cover images stored in a PDF document for each. Can I upload every PDF to the same folder? Is there some kind of limit for a folder?
Deleting Files From A Folder...
I have a folder with many pictures in it. All have the name like: HHMMDDMMYYYY.jpg H-hour M-minute D-day M-month Y-year Now I want to delete all pictures which are older than now()-7days. How Can I do it? In SQL would be no prob but with file deleting is problem.
Opening Files In The Same Folder..
I have a php file (1.php) that needs to open another php file (2.php) and parse it's output. 2.php gets it's data from an xml file and formats it in a pretty screen style. So what I need is something like: $fp = fopen ("2.php?file=file.xml","r"); but that wont work because there is no file called ƈ.php?file=file.xml' so how's it done?
Root Of Folder App Files
While I know putting a app into a folder was chiseled out of fine scottish granite and carried upto the top of ben nevis by php newbies many years ago - I dont think a folder is the best way to do it . The fact a script is in a folder means certain instant problems if you want to do certain things with . Assuming a script doesnt have index.php and all the script files have a filename prefix like phpgb_ then theres no chance of them clashing with anything else and theres no real reason to continue using a folder for the main script files . While the script will have a app folder for various things - does it make any sense not to use the root because of a single solitary file called index.php . phpgb_index.php is what I use and the method hasnt brought up a single problem of any shape or description . Gas lighting was once what everybody thought was the best way of doing it until that darn new fangled electricity came along .
1 - 2 Millions Files In One Folder?
I have to store over a million files, 10 - 15 kb each, in one folder. The files are created by my php script, sometimes the old files are deleted and new ones are written. So, basically on every connection my script reads/deletes/ writes files from/to that folder. Right now i have only around 300 000 files in that folder, and it feels like its getting slower for that script to work. It does work at the moment, but i am not sure what will happen when there is over a million files there... Are there any limits of files that can be stored in a folder? Would it be better for me to use mysql? I am not sure how mysql will cope with millions of writes/reads
How Does One Get A List Of All Files In A Folder?
need a list of all files (i have like 5k or so) in a folder, I need to add there names to a table I am doing this so i can compare two tables table 1. comments added to uploaded pics -finished pictures- table 2. no comments added yet to uploaded pics (so they can be commented on GET IT?) -unfinished pictures- All the pictures are in a single folder for the time being i'm going to be making a form based on the pictures that are on table 2 so that they can have comments and titles and file name added to table 1 (to be done still) but i need to know all the file names for the folder in question, i guess i could do it via cmd line ls or something like that, i'll get back to you.
Viewing Files In A Web Folder
I'm trying to put my files in a web dirctory. All kind of files, so that in the future when I need something I just go there and get them. My goal is that when I type "www.domain.com/myVitualDirectory" I would get my list of files and folders and files and I would even be able to navigate into the folders, then I would right click and Save Target As and get my file.
Php Include Files From A Folder
I want to make a folder filled with blog posts by date. Each file will be like 20071113.php and 20071031.php basically the date they were written 2007, 10 for october, and 31 for the day. But each will be notated like that so that the number is always increasing. How would I make a php include function as to take the last ten highest numbers and add it to a page? (Basically the last ten posts by date) and How would I include more than one post per date?
Indexing Text Files In A Folder
I'm newbie on Php. I cannot write codes but only modify. I need a code doing this: I'll put text files in a folder like file1.txt,file2.txt ... I want to search this files, list most recent 10 and if files call, script will put into the site design with <pre> tags.
Dropdown List Of Files In Folder
I am preparing a form that includes a drop-down list consisting of the names of files in a certain folder on the server. I only need to trap the file name (jpg), not the path and I'm not trying to upload the files or anything - simply allow the user to select one of a number of different image files (they're actually location maps).
Opening All Text Files In A Folder
Im very new to php and need a bit of help. basically what I have is a folder with a number of text files inside. What i need to do is open every text file in that folder and then process the information inside each text file. Im not really sure but I would assume I open the directory and place the name of each text file into an array and then loop through the array and process the contents of the text file. #open directory #foreach text file in the directory #store file name into an array #loop through array #process code
Displaying Files In A Folder Using A Calender
I have excel sheets generated daily and weekly in this format for filenames..for daily sheets the filename is Jan-10-2002 (mmm-dd-yyyy) and weekly Week-39-2002. I have a script that uploads to a constant folder all the excel sheets. Is there a script that can display the daily scripts in form of a calender. I.E a user can choose to view or download the sheet by choosing the date? Also another for displaying weekly excel sheets in a weekly format.
Return All The .html Files In A Folder?
I'm trying to find all the include files in a folder is there a way to some how read a folder and then return an array with all the file names as the array keys or associative keys? I only want to return files that are .html or .php not all files
Show Html Files In A Folder
I am trying to create a script that will parse the folder it's containing php page is in for html files. Create a drop down list of links to the html files. Anyone know how I might do this?
Deleting Files In A Folder Modified Before Certain Date
I use a cache system that requires creation of files in a folder . Now , what i need to know is how can i delete files created say 3 days ago. So that the cache remains fresh. The directory contains around 20,000 files , about 10,000 are generated each day (if they dont exist) So getting info about the each file after using opendir will cause the server to slow down.
Include Files Folder - CHMOD Settings?
Currently, I have various php files in my "public" folder on my webserver. I also have "include" php files in a designated folder w/in my "public" folder (i used include("file") Example: path files public folder => index.php, products.php, aboutus.php, etc public folder/include folder => includefile1.php, includefile2.php, etc what CHMOD settings should i set... so that users cannot directly open my "include" files? and where do i set them? on the "include" folder? on the individual "include" files?
Detecting PDF Files In A Folder And Sorting Them By Date
I am about to write an application that will display all pdf files in a folder and display them by file name in order of date. Is there an easy way of doing this? I was thinking about somehow adding filename and date created in an array, sorting by date and then printing onto an html page with a link to that file. How would I do this though? Is this the simplest method or is there a better way of doin this?
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.
I Can Upload Files Anywhere Except My Remote Root Folder
Im working on a project with PHP that allows users to upload pictures to my server and then reference them. After going through some uploading tutorials I have the uploading part working Except! I cant upload folders to my remote root folder. I need to allow the users to upload somewhere inside the root folder so they can reference the pictures in code after. Just to clarify the uploading works perfectly if I put the uploads folder anywhere on my computer except the sites remote root folder (or anywhere inside the root folder) I also beleive I am giving the folder all of the proper permissions because I am giving the uploads folder in my root directory (the one that doesnt work) the same permissions as the one outside the root (the one that works) Code:
Some Files Created Automatically In Mysql Database Folder
i have created one database in mysql. first i have created all tables are of innodb type then i converted all tables to myisam type. i know that for each myisam type table three files are created tablename.frm tablename.myi and tablename.myd. i have created database before one month. today i checked database and i show somefiles exist in database folder named (1)#sql-644_27.frm (2)#sql-644_1.frm (3)#sql-638_1.MYI (4)#sql-638_1.MYD (5)#sql-638_1.frm (6)#sql-478_5.frm can anyone tell me what is these files and why is these files?
How To Move Files To The "lib" Folder?
A client recently asked me to move a lot of code into the "lib" folder...and I'm not sure exactly how to do this without having the site blow up. I'm using Subversion and have a root-level folder structure that looks like this: * lib * logs * sql * src Currently, I have all of my web files in the "src" folder. There is a folder of include files in the "src > includes" folder. The client is asking to move these to the "lib" folder for security reasons. How do I do this?! I'm not sure how to move files outside the "src" folder and have the site still function properly.
Remove From $name (folder)/(folder)/[x]/ <-- If Exists To Just Get [x].
I'll be quite honest. I don't have the faintest idea how to do this, while I can do other php without a problem. Once I know how to go about it I'll be okay. It's two things I think? 1. see if there's a trailing slash and delete it. 2. Remove the preceding path to /x, the folders and slashes, and delete them. and then I have x. X by the way is the final folder in a website and this grabs it for me. <? $name = $REQUEST_URI; ?>
Recursive Call
I'm having some problems with a recursive call. Basically I have a standard tree of nodes, and a function _calcSize() which takes a node as a parameter and returns the size of the node: PHP Code:
Recursive Function
i'm writing a tree menu which is database driven. basically i'd like to have it loop infinitely if needed. my table structure is simple for starting out: table: categories cid, category, parent i found a function that works perfectly in pulling the data recursively, however i had problems formatting the javascript for the tree menu correctly, so i ventured out on my own. however i've become stuck. the class is below, it's the last two functions which create the Javascript. denoted by "problem area" in the last if($branches) statement PHP Code:
Recursive Array
I have a category system in my product guide and the tables look like this: Table Categories - category_id - category_directory - is_product_category Table Categories_Xref - category_pid - category_id When I create a category it can go any level deep but I flag the final category (the product category) with the "is_product_category" field in the Categories table. An example looks like this: Systems -- Servers ---- PA-RISC ------ N Class Servers (is_product_category) -------- Product 1 -------- Product 2 -------- Product 3 Systems -- Servers ---- Intel ------ LH Series (is_product_category) -------- Product 1 -------- Product 2 -------- Product 3 Systems -- Workstations ---- PA-RISC ------ C Class Workstations (is_product_category) -------- Product 1 -------- Product 2 -------- Product 3 Now, when I am at the "Systems" level in the product guide I want to be able to find all the product categories that fall below below that category. In this case I should end up with the three above: N Class Servers, LH Series, C Class Workstations. When I click on the next category "Servers", my final product categories will be: N Class Servers, LH Series. This is what I came up with but unfortunately it only goes through one of the branches but not all. PHP Code:
Recursive - Like Variables
Say I want a variable to equal a part on an array til all the way to the end of the array or from the point i specify to the beginning.. Anybody know how to do this? $_this = $array[5] . (all the way down to array[0]); or $_this = $array[5] . (all the way to the end of the array, end($array);
Can't Get Head Around Recursive Function.
My question relates to a directory site I'm working on. I have an ID for a category. This is likely the child of child of a child, etc. category. For example - Holiday: Travel: Plains Given that the ID for plains is, say 10, I want to build the above with navigation, ie. looking like:
Recursive Database Delete
I have two tables in my database, one for the folders, where each folder has a parent id and an id itself, and one for the files where each file has a parent id for the folder its in. Now If the user deletes a folder, every file and folder within it, no matter how many there are, should be deleted. Can anyone give me the idea?
Possible Bug With Recursive Array References
I am using PHP 5.0.4 with Apache 2, on WinXP Pro. This behavior appears to be fundamental however, and should not be affected by platform. It would seem that there is some kind of bug in the process that creates the reference when it is being assigned to an array element within itself. If it is already referenced, it just assigns the existing reference and avoids the problem. As I was reading the documentation about references, I noticed the warning about "complex arrays". Here is what it says: ----- begin PHP docs ----- Complex arrays are sometimes rather copied than referenced. Thus following example will not work as expected. Example 21-3. References with complex arrays <?php $top = array( 'A' => array(), 'B' => array( 'B_b' => array(), ), ); $top['A']['parent'] = &$top; $top['B']['parent'] = &$top; $top['B']['B_b']['data'] = 'test' print_r($top['A']['parent']['B']['B_b']); // array() ?> ----- end PHP docs ----- So I decided to play around with this, and sure enough I got the same results. But after making a few changes, I discovered that the behavior is caused by recursively assigning the reference, and not due to the array structure itself. Consider this example code: <?php $top = array( 'X' => 1, 'Y' => 1, 'Z' => 0 ); $top['Y'] = &$top; $top['X'] = &$top; $top['Z'] = 4; echo "X = ", var_dump( $top['X']['Z'] ); echo "Y = ", var_dump( $top['Y']['Z'] ); echo "Z = ", var_dump( $top['Z'] ); ?> The results show: X = int(0) Y = int(4) Z = int(4) The result for X still has the original value. This would seem to agree with the orginal statement in the PHP docs. But, if you reverse the order of the reference assignments like this: $top['Y'] = &$top; $top['X'] = &$top; $top['Z'] = 4; Then, the result for Y has the original value. X = int(4) Y = int(0) Z = int(4) Furthermore, if you assign some arbitrary variable a reference to $top before doing anything else... $z = &$top; The output appears to be "correct" now: X = int(4) Y = int(4) Z = int(4) Looking at the var_dump of the actual resulting array struct reveals that where the reference is being assigned matches the contents of the array at *that point in time* up until the next recursive reference assignment. At that point $top branched off, leaving the first one pointing to the previous instance. So it would appear that it is actually a fractal array structure :) Each member that gets another ref to $top adds another fractal generation to the var_dump. But nonetheless, assigning a reference to a separate variable stops the branching for all subsequent recursive reference assignments. So it appears that assigning a reference to an element within itself like that does not correctly create the reference, unless the reference was already created. Another way to demonstrate this is to compare the output of these two scripts: <?php $top = array( 'W' => 1, 'X' => 1, 'Y' => 1, 'Z' => 0 ); $top['WW'] = 'wwwww' $top['W'] = &$top; unset ( $top['WW'] ); $top['XX'] = 'xxxxx' $top['X'] = &$top; unset ( $top['XX'] ); $top['YY'] = 'yyyyy' $top['Y'] = &$top; unset ( $top['YY'] ); $top['Z'] = 4; var_dump( $top ); ?> <?php $top_t = array( 'W' => 1, 'X' => 1, 'Y' => 1, 'Z' => 0 ); $top_t['WW'] = 'wwwww' $top_w = $top_t; $top_w['W'] = &$top_w; unset ( $top_w['WW'] ); $top_w['XX'] = 'xxxxx' $top_x = $top_w; $top_x['X'] = &$top_x; unset ( $top_x['XX'] ); $top_x['YY'] = 'yyyyy' $top_y = $top_x; $top_y['Y'] = &$top_y; unset ( $top_y['YY'] ); var_dump( $top_y ); ?> Basically, the output is the same, except that in the first one, the dump of $top['Y']['Y'] is shorted to "*RECURSION*" but not in the second. Now compare the output of these two scripts: <?php for ( $i = 0; $i < 10; $i ++ ) $top[$i] = &$top; $top['A'] = 'AAAAA' var_dump( $top ); ?> <?php $z = &$top; for ( $i = 0; $i < 10; $i ++ ) $top[$i] = &$top; $top['A'] = 'AAAAA' var_dump( $top ); ?> The only difference is the reference assignment at the beginning of the second one. But the results differ vastly. The first outputs over 157457 lines, while the second only outputs about 2554 lines. What I would like to know, is if this is actually a bug, or if this behavior is intentional. I do not have much knowledge of how the Zend Engine creates the references. But I find it at least somewhat dangerous that it can have that "fractal" effect so easily. And since it can be avoided by simply setting a reference to a separate variable, I am convinced that something is broken (or at least VERY confusing). The design of the language does not seem to justify this statement: "make a direct reference assignment to the array before adding recursive references inside it, or else the structure will branch with each assignment" So... any thoughts?
Recursive Category Display?
I'm trying to put together a file download system with categories / subcategories. I made the following 3 tables: Code: FILES ------------------------------------------ FILE_ID NUMBER FILE_NAME VARCHAR2 FILE_DESC VARCHAR2 FILE_DL_COUNT NUMBER FILE_CATEGORIES ------------------------------------------- CAT_ID NUMBER CAT_NAME VARCHAR2 CAT_DESC VARCHAR2 PARENT_ID NUMBER FILE_CATEGORIES_REL ------------------------------------------- FILE_ID NUMBER CAT_ID NUMBER I am using Oracle, so no worries about the non mysql data types. So I have been looking at freeware code for about 2 days and I can't understand how to create a function that recursively displays my categories. Ideally I am trying to output a table Such that when I click on a category, it displays sub categories and files within it.
|