Forum Articles
  Welcome back Join CF
You are here You are here: Home | Forum | need help with pointing to an ubuntu directory. Using LAMPP

You are currently viewing our boards as a guest which gives you limited access to view most of the discussions, articles and other free features. By joining our Virgin Media community you will have full access to all discussions, be able to view and post threads, communicate privately with other members (PM), respond to polls, upload your own images/photos, and access many other special features. Registration is fast, simple and absolutely free so please join our community today.


Welcome to Cable Forum
Go Back   Cable Forum > Computers & IT > General IT Discussion
Register FAQ Community Calendar

need help with pointing to an ubuntu directory. Using LAMPP
Reply
 
Thread Tools
Old 25-03-2009, 11:57   #1
funkyCable
Inactive
 
Join Date: Aug 2005
Location: Canvey Island, Essex
Services: SERVICES FROM 26/08/05 TV XL services 2MB BROADBRAND UNLIMITED TALK PACKAGE V+ Service (Since 18
Posts: 1,195
funkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nice
need help with pointing to an ubuntu directory. Using LAMPP

Hi

I'm trying to create a php script that will read all directorys/files from a specific folder and place the paths into a mysql db.

As I am new to PHP/apache I wondered how I could do this. I see php has a scandir function and I tried the following bit of code which returned some files but I have no idea where its getting its info.
PHP Code:
 <?php 
$dir    
'/tmp'
$files1 scandir($dir); 
$files2 scandir($dir1); 

print_r($files1); 
print_r($files2); 
?>
I did a the normal LAMPP installation on my ubuntu machine. I know my installation is stored under /opt/lampp and my webpages are under /opt/lampp/htdocs.

My question is how do I point to another directory in PHP. I want to point to /opt/lampp/web_site_copy/pictures

Do i need to make changes to my apache config file and if so how do i do it?

I looked throught my phpinfo() and doc_root is not specifed and neither is user_doc.

Thanks for your help.
funkyCable is offline   Reply With Quote
Advertisement
Old 25-03-2009, 12:20   #2
TheDon
Inactive
 
Join Date: May 2007
Posts: 1,567
TheDon has reached the bronze age
TheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze age
Re: need help with pointing to an ubuntu directory. Using LAMPP

You should just be able to use the absolute path, so setting $dir to /opt/lampp/web_site_copy/pictures should let php see them.

The real question is what you then want to then do with the paths?

If as I suspect you want to use them to create a page of links to them or some such so as you can serve the files from a webpage then yes, you'll need to alter your apache config so as your DocumentRoot is /opt/lampp/web_site_copy/ or store the pictures under /opt/lampp/htdocs/pictures which is the easier solution.
TheDon is offline   Reply With Quote
Old 25-03-2009, 12:37   #3
funkyCable
Inactive
 
Join Date: Aug 2005
Location: Canvey Island, Essex
Services: SERVICES FROM 26/08/05 TV XL services 2MB BROADBRAND UNLIMITED TALK PACKAGE V+ Service (Since 18
Posts: 1,195
funkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nice
Re: need help with pointing to an ubuntu directory. Using LAMPP

Thanks that worked perfectly.

I am hoping to do some AJAX and fetch the next/previous pictures. Do you think its worth storing the paths in a table or just keep using the scandir and loop through the directory/files in the array? I have over 6gigs of pictures and videos to follow.
A shiney is on its way.
funkyCable is offline   Reply With Quote
Old 25-03-2009, 13:06   #4
TheDon
Inactive
 
Join Date: May 2007
Posts: 1,567
TheDon has reached the bronze age
TheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze ageTheDon has reached the bronze age
Re: need help with pointing to an ubuntu directory. Using LAMPP

Using scandir every time and building the array will give a pretty significant performance hit, so using a table would probably be the easiest way to do it.

Then you'd just need a separate script that you run when you've added pictures to the directory to add them to the table.
TheDon is offline   Reply With Quote
Old 25-03-2009, 13:26   #5
funkyCable
Inactive
 
Join Date: Aug 2005
Location: Canvey Island, Essex
Services: SERVICES FROM 26/08/05 TV XL services 2MB BROADBRAND UNLIMITED TALK PACKAGE V+ Service (Since 18
Posts: 1,195
funkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nice
Re: need help with pointing to an ubuntu directory. Using LAMPP

What if a picture has been removed or the link in the table is old as the file has been moved to another location?

Do you know if you can create sceduled jobs in mysql like you do with ORACLE?

So I should perhaps have a temp directory that I use to pick up the files/directories
create a reference and store it in the table and once this is done successfully move it to the relivant permanent folder where the image will reside.

---------- Post added at 14:26 ---------- Previous post was at 14:22 ----------

I'm trying to determine whether the path is part of a directory or a file.

PHP Code:
<?php
$dir    
'/opt/lampp';
$files1 scandir($dir);
$files2 scandir($dir1);
?>
Directory <br />
<?php
foreach ($files1 as $fileobject){
  if (
is_dir($fileobject)){
    echo 
"$fileobject<br>";
  }
}
?>
Files:<br />
<?php
foreach ($files1 as $fileobject){

  if (
is_dir($fileobject)==FALSE){
    echo 
"$fileobject<br>";
  }
}
?>
Under the directory I get "." and ".." and under files I get all the files and directories. I tried the is_file() function and that did not help neither
funkyCable is offline   Reply With Quote
Old 25-03-2009, 13:29   #6
Raistlin
Inactive
 
Join Date: Feb 2004
Location: There's no place like 127.0.0.1
Services: Depends on the person and the price they're offering
Posts: 12,384
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Re: need help with pointing to an ubuntu directory. Using LAMPP

"." is the file system's internal reference to the folder that you're currently in.

".." is the file system's internal reference to the parent folder for the folder that you're currently in.

---------- Post added at 14:29 ---------- Previous post was at 14:28 ----------

If you go to a command prompt and type dir you will get a listing of the directory contents, and should see that the first to entries are:
Code:
.
..
Raistlin is offline   Reply With Quote
Old 25-03-2009, 13:32   #7
funkyCable
Inactive
 
Join Date: Aug 2005
Location: Canvey Island, Essex
Services: SERVICES FROM 26/08/05 TV XL services 2MB BROADBRAND UNLIMITED TALK PACKAGE V+ Service (Since 18
Posts: 1,195
funkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nice
Re: need help with pointing to an ubuntu directory. Using LAMPP

Thanks Rob I figures that one out but what is puzzling me is the fact that it says that
/opt/lampp/etc/ is a file when it should be a directory
funkyCable is offline   Reply With Quote
Old 25-03-2009, 13:36   #8
Raistlin
Inactive
 
Join Date: Feb 2004
Location: There's no place like 127.0.0.1
Services: Depends on the person and the price they're offering
Posts: 12,384
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Re: need help with pointing to an ubuntu directory. Using LAMPP

That's because in Linux everything is treated as a file

Linux doesn't really deal with file objects and directory objects, it just deals with different types of file object.

'Directories' are actually nothing more than a file that points to other files.
Raistlin is offline   Reply With Quote
Old 25-03-2009, 13:45   #9
funkyCable
Inactive
 
Join Date: Aug 2005
Location: Canvey Island, Essex
Services: SERVICES FROM 26/08/05 TV XL services 2MB BROADBRAND UNLIMITED TALK PACKAGE V+ Service (Since 18
Posts: 1,195
funkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nice
Re: need help with pointing to an ubuntu directory. Using LAMPP

I see sorry I'm originally from a windows background and used to use DOS back in the day so I do remember all the cd.. commands etc.

If thats the case what method could I use to determine whether the file is a directory or a file. I need to know this so that if its a directory it need to cd to that directory and start the go through all that directories contents. I see theres a filetype() function but that seems to break when the filetype is not a dir.
funkyCable is offline   Reply With Quote
Old 25-03-2009, 13:51   #10
Raistlin
Inactive
 
Join Date: Feb 2004
Location: There's no place like 127.0.0.1
Services: Depends on the person and the price they're offering
Posts: 12,384
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Re: need help with pointing to an ubuntu directory. Using LAMPP

I'm not familiar with the functions that you're using, but is there anything in the output of the function you're using to list the directory content that you could use to determine what's a directory and what isn't?

Failing that, is there a function that you can use to get the size of the object? If it has a size of 0 (zero) it's probably a directory, anything other than that and it's a file.

I say probably because it's possible to get a file with zero size, but unlikely.....maybe
Raistlin is offline   Reply With Quote
Old 25-03-2009, 13:59   #11
funkyCable
Inactive
 
Join Date: Aug 2005
Location: Canvey Island, Essex
Services: SERVICES FROM 26/08/05 TV XL services 2MB BROADBRAND UNLIMITED TALK PACKAGE V+ Service (Since 18
Posts: 1,195
funkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nice
Re: need help with pointing to an ubuntu directory. Using LAMPP

Good thinking about the 0 file size

I busy looking through these functions http://www.w3schools.com/php/php_ref_filesystem.asp
PHP Code:
<?php
$dir    
'/opt/lampp';
$files1 scandir($dir);
$files2 scandir($dir1);
?>
Directory <br />
<?php
foreach ($files1 as $fileobject){
  if (
is_dir($fileobject)){
    echo 
"$fileobject<br>";
  }
}
?>
Files:<br />
<?php
foreach ($files1 as $fileobject){

  if (
is_dir($fileobject)==FALSE){
    echo 
"$fileobject<br>";
  }
}
?>
File type:<br />
<?php
foreach ($files1 as $fileobject){

  
//if (is_dir($fileobject)==FALSE){
    
echo "$fileobject : " filetype($fileobject) . "<br>";


}

?>
this is my testing code at the moment.
funkyCable is offline   Reply With Quote
Old 25-03-2009, 14:06   #12
Raistlin
Inactive
 
Join Date: Feb 2004
Location: There's no place like 127.0.0.1
Services: Depends on the person and the price they're offering
Posts: 12,384
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Re: need help with pointing to an ubuntu directory. Using LAMPP

Does the $fileobject variable just give you a file/directory name?

---------- Post added at 15:06 ---------- Previous post was at 15:03 ----------

When you say filetype() breaks things when they're not a directory what results do you actually get?
Raistlin is offline   Reply With Quote
Old 25-03-2009, 14:15   #13
funkyCable
Inactive
 
Join Date: Aug 2005
Location: Canvey Island, Essex
Services: SERVICES FROM 26/08/05 TV XL services 2MB BROADBRAND UNLIMITED TALK PACKAGE V+ Service (Since 18
Posts: 1,195
funkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nice
Re: need help with pointing to an ubuntu directory. Using LAMPP

You were right it was just a filename/directory name not an actual path.

PHP Code:
<?php
  $dir    
'/opt/lampp';
  
$files1 scandir($dir);
?>
Directory <br />
<?php
  
foreach ($files1 as $fileobject){
    
$file $dir "/" $fileobject;
    if (
is_dir($file)){
    echo 
"$fileobject<br>";
  }
}
?>
<br /><b>Files:</b><br />
<?php
foreach ($files1 as $fileobject){
  
$file $dir "/" $fileobject;
  if (
is_file($file)){
    echo 
"$fileobject<br>";
  }
}
?>
<br /><b>File type:</b><br />
<?php
  
foreach ($files1 as $fileobject){
    
$file "/opt/lampp/" $fileobject;
    echo 
"$fileobject : " filetype($file) . "<br>";
  }
?>
<br /><b>File Sizes:</b><br />
<?php
  
foreach ($files1 as $fileobject){
    
$file "/opt/lampp/" $fileobject;
    echo 
filesize($file) . "<br>";
  }
?>
This clearly shows what is a directory and what is a file.
funkyCable is offline   Reply With Quote
Old 25-03-2009, 14:16   #14
Raistlin
Inactive
 
Join Date: Feb 2004
Location: There's no place like 127.0.0.1
Services: Depends on the person and the price they're offering
Posts: 12,384
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Re: need help with pointing to an ubuntu directory. Using LAMPP

Does that mean you're all sorted?

Cool Nice on
Raistlin is offline   Reply With Quote
Old 25-03-2009, 14:23   #15
funkyCable
Inactive
 
Join Date: Aug 2005
Location: Canvey Island, Essex
Services: SERVICES FROM 26/08/05 TV XL services 2MB BROADBRAND UNLIMITED TALK PACKAGE V+ Service (Since 18
Posts: 1,195
funkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nice
Re: need help with pointing to an ubuntu directory. Using LAMPP

Yip thanks for your help.

Unfortunately cable forum not allow me to add to your reputation because I've already given you some reputation from one of my other queries.
funkyCable is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:16.


Server: lithium.zmnt.uk
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum