Twentyoneth Posted March 25, 2006 Share Posted March 25, 2006 I am trying to use opendir() on my main directory [http://site.com] but I can only get it to work on other dirs inside my main directory [articles/], how do I tell opendir() to read from the main directory? Quote Link to comment Share on other sites More sharing options...
toplay Posted March 25, 2006 Share Posted March 25, 2006 You should always post your code to help members on this forum help you.You should really be using path names and not URL's. See:[a href=\"http://us2.php.net/manual/en/function.opendir.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.opendir.php[/a]p.s. The directories must have the correct permissions to allow the PHP script to open a directory. Quote Link to comment Share on other sites More sharing options...
Twentyoneth Posted March 25, 2006 Author Share Posted March 25, 2006 ok, I have an opendir() command, it will only let me use directories off of my main directory, like "articles/" and "images/", but I want to have it open my main directory, [a href=\"http://site.com\" target=\"_blank\"]http://site.com[/a], not site.com/articles/. Here is the code, maybe someone could give an easier way to go about this.zipit.php (in "zipclass" directory with "zipfile.php")[code]$UID = $HTTP_COOKIE_VARS['UID'];if ($UID == '1') {include('zipfile.php');if ($_POST['submit']) { $directory = opendir('http://site.com'); while ($file = readdir($directory)) { $file_array[] = $file; }[/code]That is just a segment of my code, is there something like a php phrase that tells it the base directory of the site? Or something like "../" to tell it to open the directory before "zipclass"? Quote Link to comment Share on other sites More sharing options...
Twentyoneth Posted March 28, 2006 Author Share Posted March 28, 2006 This code is used for the zip class, I am trying to provide my main directory to be zipped, but I cant get it to open any directory and save the files. Quote Link to comment Share on other sites More sharing options...
Twentyoneth Posted March 30, 2006 Author Share Posted March 30, 2006 This is the class off of zend I do believe. Which creates a zip file.[a href=\"http://nicotinejunkie.cv.vc/zipclass/code1.txt\" target=\"_blank\"]code1[/a]This is my code, which adds files to the zip.[a href=\"http://nicotinejunkie.cv.vc/zipclass/code2.txt\" target=\"_blank\"]code2[/a]The problem is, no matter where I set the opendir() to, it wont add any files. My main objective is to add all of the files in my entire site to this zip file, I dont know how to go about it. But I cant even get it to add files from one directory on my site. These two files are in 'zipclass' directory (http://site.com/zipclass/), and even upon moving them to my main directory (http://site.com/), I get no files added to the zip. What am I doing wrong? And is there any hints as to how I can add all files from all directories. And if possible how to keep the structure of directories and which files go in which (not a must).Thanks. Quote Link to comment Share on other sites More sharing options...
txmedic03 Posted March 30, 2006 Share Posted March 30, 2006 [code] opendir('./');[/code]Use relative paths not URLs../ = current directory../ = parent directory../otherdirectory/ = directory on same level in tree with the current onesubdirectory/ = a directory inside of the current one.You get the idea...I use the trailing slash because it makes it easy if you set a variable like $path = "subdirectory/"; then opendir() can open it and if you have a particular file like file.txt for example you can simply say $filenameandpath = $path."file.txt"; It could be done by remembering the '/' between $path and file.txt, so it really six of one half a dozen of the other, but this is just my prefered method. Quote Link to comment Share on other sites More sharing options...
Twentyoneth Posted March 30, 2006 Author Share Posted March 30, 2006 I have tried '../ ' to get to the parent directory, but it wont add any files to the zip.I have also tried '../images' and '../images/' and none of those worked.I have also moved my files to the parent directory and tried 'images/' and nothing, for some reason it wont add any files to the zip. I dont know what is wrong with my code to add files to the zip, and I'm not sure if ../ to the parent directory will add all the files on my entire site, with directories and subdirecties. Quote Link to comment Share on other sites More sharing options...
Twentyoneth Posted April 3, 2006 Author Share Posted April 3, 2006 Anyone? Quote Link to comment Share on other sites More sharing options...
txmedic03 Posted April 3, 2006 Share Posted April 3, 2006 It will only add them if you have the code setup to parse sub-directories. Without seeing more of your code I don't think I can provide a solution to your problem. Personally, I don't use compression to make back-ups of servers. I use a cron job setup to make a copy every night at midnight from each of my or my clients' servers. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.