Jump to content


Photo

file directories, and directory access/structure


  • Please log in to reply
3 replies to this topic

#1 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 16 October 2006 - 03:06 PM

Can someone tell me some stuff about directories, directory structures, and accessing files within a directory.
Or show me a good tutorial on it, I looked everywhere for something pretty good.

I need to know stuff like how to access them.
When to put ./, when to put / or ../ I had someone help me with it some, but I don't really understand.
I know a little, but that's one of my weak spots, any advice?

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#2 makeshift_theory

makeshift_theory
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts

Posted 16 October 2006 - 03:11 PM

Well I had the same dilema, I was trying to ftp a local site structure to a remote location and after a week of testing I finally got it to work, below is the script.  It goes through each directory in the local side and uploads the files to a remote destination.

By the way I "x'ed" out all of the ftp variables so don't actually use test.com haha

<?
/* 
	FTP Upload Script
	
	Variable Definition:
	
	$detail if turned on (with any variable passed to it) will display all error messages and system messages
	
	Psuedocode: Grab All Files from local
					Create First Folder Name
					Change Directory to Created
						Check if File or Folder
							-> If File Upload to Directory
							-> If Folder Create Folders and cycle back through process with this name as the "FROM"
	
	### Written By: Christopher Willard ###
	########### Date: 10/16/06 ############
	

*/




function ftp_dwn($fromDir,$toDir,$chmod,$detail) {

// Initialize FTP Server
$ftp_server = "ftp.test.com";
$ftp_user_name = "########";
$ftp_user_pass = "#@#@#@#@#@#@#@";
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if((!$conn_id) || (!$login_result))
	$error[] = "Could not Connect to the FTP Server";

   ftp_mkdir($conn_id, $toDir);
   ftp_site($conn_id, 'CHMOD 0777 '.$toDir);
   ftp_chdir($conn_id,$toDir); // First run this will be custom/

//echo ftp_pwd($conn_id); // Test to see the current ftp directory;

// Initialize Exception Array
$exceptions = array('.','..');


	if ($handle = opendir($fromDir)) {
	   while (false !== ($file = readdir($handle)))
	   		if (!in_array($file,$exceptions)) {
			// handle slash exceptions
			$from=str_replace('//','/',$fromDir.'/'.$file);
			
			   if (is_file($from)) 
			   { // If local file is a file handle here
			   	  //echo $toDir . "/" . $file . "<br><br>";
				  if(!ftp_put($conn_id,$file,$from,FTP_ASCII))
				  $error[] = "Could not upload " . $toDir . "/" . $file . " correctly<br><br>";
				  if(!ftp_site($conn_id,$chmod,$toDir . "/" . $file))
				  $error[] = "Could not chmod " . $toDir . "/" . $file . " successfully.<br><br>";
			   }
			    
			   if(is_dir($from))
			   { // If local file is a folder handle here
				   ftp_dwn($from,$toDir . "/" . $file,$chmod,$detail=1); // $toDir = custom/css
			   }
			

			   
	   		} // End Exception IF
		
	   closedir($handle);
	} else
	$error[] = "Cannot Find Source Folder!"; // End Directory Handling
	
if($detail) { // If Error Detail Is Turned On

	foreach ($error as $err)
		echo "<font color=red><b>" . $err . "</b></font>";
		
	if(!$error)
		echo "<font color=navy><b>FTP Structure Uploaded Successfully.</b></font>";
}


} // End Function

ftp_dwn($fromDir = "cwillard/sites/BioPharm/website/",$toDir = "custom",$chmod = 0755,$detail = 1);
?>

<b>Emacs</b> it's great for the body.
<br><br>
<b>Trust the TechnoLust</b>

<b><u>Have a question check here:</u></b>
PHP Manual: http://www.php.net

#3 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 16 October 2006 - 03:47 PM

actually that will help a lot, I appreciate it.

Thanks again.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#4 makeshift_theory

makeshift_theory
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts

Posted 16 October 2006 - 04:17 PM

No problem.  I fought for a week with that script so I definately don't mind passing it on to save others the headache.
<b>Emacs</b> it's great for the body.
<br><br>
<b>Trust the TechnoLust</b>

<b><u>Have a question check here:</u></b>
PHP Manual: http://www.php.net




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users