Pics uit folder halen

Gestart doorJob12 reacties70 weergaven

13 berichten · pagina 1 van 1

Job

Lid · Topicstarter

Berichten
425
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo,
Mijn vraag is of het mogelijk is om na het uploaden van een foto, via een upload script ze vervolgens op de index.php te laten zien, en hoe dat mogelijk is. Ze staan in een map, genaamd uploads.

Groeten Job
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Kijk eens naar de functie [func]glob[/func]
0
Berichten
1.284
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Codeblok (voorbeeld.php):

1
2
3
4
5
6
7

$path= "afbeeldingen/";
$afb= glob($dirname."*.png");
foreach($afb as $afbeelding) {
echo Afbeelding niet beschikbaarDe oorspronkelijke afbeelding of link ontbreekt..$afbeelding." />
;
}

?>
0
Job

Lid · Topicstarter

Berichten
425
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
@mounssif, probeer ik maar ik krijg de foutmelding

Warning: Invalid argument supplied for foreach() in /home/domein/domains/URL/public_html/index.php on line 7


Ik heb al geprobeerd op te lossen maar lukt niet.
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Job schreef:
@mounssif, probeer ik maar ik krijg de foutmelding
Warning: Invalid argument supplied for foreach() in /home/domein/domains/URL/public_html/index.php on line 7


Ik heb al geprobeerd op te lossen maar lukt niet.

Zijn je bestanden echt .png genaamd?
0
Berichten
4.214
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Mounssif schreef:
Codeblok (voorbeeld.php):
1
2
3
4
5
6
7

$path= "afbeeldingen/";
$afb= glob($dirname."*.png");
foreach($afb as $afbeelding) {
echo Afbeelding niet beschikbaarDe oorspronkelijke afbeelding of link ontbreekt..$afbeelding." />
;
}

?>
Job schreef:
@mounssif, probeer ik maar ik krijg de foutmelding
Warning: Invalid argument supplied for foreach() in /home/domein/domains/URL/public_html/index.php on line 7


Ik heb al geprobeerd op te lossen maar lukt niet.

$dirname word nergens vastgesteld. Wel $path vervang $dirname eens met $path
0
Job

Lid · Topicstarter

Berichten
425
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
De code ziet er nu zo uit

[COLOR= #0000BB]<?php
$path[/COLOR][COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"upload/"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$afb[/COLOR][COLOR= #007700]=[/COLOR] [URL="http://www.php.net/glob"]glob[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$path[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"*.jpg"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$afb[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$afbeelding[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<img src="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$afbeelding[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" /><br />[/COLOR][COLOR= #007700];
}[/COLOR]

?>


En ik heb nog steeds de error.
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Debuggen
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
var_dump($afb);
0
Berichten
528
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$path[/COLOR][COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"one2xs/"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$afb[/COLOR][COLOR= #007700]=[/COLOR] [URL="http://www.php.net/glob"]glob[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$path[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"*.png"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$afb[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$afbeelding[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$afbeelding[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]<br />[/COLOR][COLOR= #007700];
}[/COLOR]

?>


getest en werkt prima bij mij.

toevoeging op 5 september 2013, 12:36:24:
heb je wel minimaal php 4.3.0?
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Rudie schreef:
[COLOR= #0000BB]<?php
$path[/COLOR][COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"one2xs/"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$afb[/COLOR][COLOR= #007700]=[/COLOR] [URL="http://www.php.net/glob"]glob[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$path[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"*.png"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$afb[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$afbeelding[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$afbeelding[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]<br />[/COLOR][COLOR= #007700];
}[/COLOR]

?>
getest en werkt prima bij mij.

toevoeging op 5 september 2013, 12:36:24:
heb je wel minimaal php 4.3.0?

Dan had hij vast wel een undefined function-melding gehad.
0
Berichten
528
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
das waar.
Folder zal ook wel read rechten hebben.
0
Berichten
473
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Job schreef:
De code ziet er nu zo uit

[COLOR= #0000BB]<?php
$path[/COLOR][COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"upload/"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$afb[/COLOR][COLOR= #007700]=[/COLOR] [URL="http://www.php.net/glob"]glob[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$path[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"*.jpg"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$afb[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$afbeelding[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<img src="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$afbeelding[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" /><br />[/COLOR][COLOR= #007700];
}[/COLOR]

?>
En ik heb nog steeds de error.

In de hoofdpost zeg je dat je map uploads heet, dus misschien is dat de fout?
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren