View Full Version : Importing data from folder step 1

12-09-2003, 09:55 PM
Okay, in my attempt to create this app, I have come across this problem, One of many.

I have a folder on a server that contain images, .tifs. How can I import a list of the content into a drop down list in a php page?

(Project over view)

Dylan Leblanc
12-09-2003, 10:20 PM
Use these functions to read a directory's contents: http://ca3.php.net/manual/en/function.opendir.php

12-09-2003, 10:43 PM
I added this piece of code and got this error. I image directory is testimges which is in the same directory as the php page.

$dir = "testimages";

// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
print "filename: $file : filetype: " . filetype($dir . $file) . "\n";

Warning: filetype(): Lstat failed for (null) (errno=2 - No such file or directory) in /usr/local/apache/htdocs/main/applications/imagefrontend/TMPkhtddpndhz.php on line 63

Dylan Leblanc
12-09-2003, 11:20 PM
You will need a slash on the end of the dir, like in the example you copied from.

12-11-2003, 03:59 PM
Okay I get it to work if the directory is a sub directory. What if the directory that I am trying to access is higher up? Say 4 folders up. One more thing is there any way to make the content of the folder appear in a drop down list? Thanx your help is greatly appriciated!

Dylan Leblanc
12-11-2003, 04:32 PM
Yes, all that can be done. It would be good for you to learn how to do these kind of things if you are going to program a website. There is lots of documentation to learn from online.

12-11-2003, 06:56 PM
What sites do you recommend for a newbie, trying to learn php? I got the books and bookmarket php.net.