![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
|
opendir() issue
i want to load my files from a directory into an array. my code thus far is
<?php #set up the array $dir = "www.sbwelding.com//images/hand/"; $files = array(); $directory = opendir($dir); while($filename = readdir($directory)){ if(strlen($filename) > 2){ array_push($files, $filename); } } foreach($files as $name) { echo "<img src='$name.jpg'> <br>"; } ?> i get the error: Warning: opendir(www.sbwelding.com//images/hand/) [function.opendir]: failed to open dir: Invalid argument in C:\serve\www\hand.php on line 12 Warning: readdir(): supplied argument is not a valid Directory resource in C:\serve\www\hand.php on line 13 i also tried using just /images/hand for a dir and it didnt work |
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Psst... make sure you have PHP 5, and check this out.
|
|
|
|
|
|
#3 |
|
Newbie
|
is_dir()
i tested the dir with the is_dir function and it failed, so that means that it is not recognizing it. my only problem is from where the file is that would be the right dir and i also test with the full url and not anything local
|
|
|
|
|
|
#4 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
You have two forward-strokes in a row in that string:
$dir = "www.sbwelding.com//images/hand/"; |
|
|
|
|
|
#5 |
|
Newbie
|
tried
i have php 5 and i also tried it without the double // which i think it should be.
i get the same error as before with the invalid argument on the line where i have the opendir() function. |
|
|
|
|
|
#6 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Dare I suggest you also check out the forum's rules/FAQ and a "How to Post..." thread, despite the fact they have nothing to do with your problem? Matter of courtesy and community, donchano.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#7 |
|
Newbie
|
i still need help. i have tried everything i can think of
|
|
|
|
|
|
#8 | |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Well, I pointed my browser to http://www.sbwelding.com/images/hand/, and I got this message:
Quote:
|
|
|
|
|
|
|
#9 |
|
Newbie
|
i just put the tag
<img src="/images/hand/000_0291.jpd"> and it displayed the picture and this is in the same file |
|
|
|
|
|
#10 |
|
Hobbyist Programmer
Join Date: Oct 2005
Posts: 134
Rep Power: 4
![]() |
Don't use the URL for the directory. Use the path on your server to that dir. For example:
$dir = 'C:\serve\www\images\hand'; |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|