Jump to content

earlier uploaded files dont show?!


masterens

Recommended Posts

hi everyone

 

i am currently making my website with an uploadform. The upload function is working, but now i am trying to make the site remember the last 5 uploads. The filenames should appear in an array:

$aotf[0]

$aotf[1]

$aotf[2]

$aotf[3]

$aotf[4]

and since all files that can be/are uploaded are images, i want them to be drawed next to each other, each 128x128. THAT is working, but the fetch for images doesn't. When an image is uploaded, i execute this code:

	    $readhandle=fopen("uploaddb.log","r");
    $aotf=fread($handle,filesize("uploaddb.log"));
    fclose($readhandle);
    $writehandle=fopen("uploaddb.log","w");
    fwrite($writehandle,"$aotf\r\n" . "uploadform/gebruikers/" . $naam);
    fclose($writehandle);

then,there is some html code, and then there is this code:

$aotf=explode("/n",$aotf);
for($i = count($aotf) - 5; $i <= count($aotf); $i++) {
echo ' <img src="'. $aotf[$i] . '" width="128" height="128"> ';
}

when i open the page, all img src's are empty. The writing works, and the folder of the image is 7777 chmod and the images draw on the screen, but not as the last uploaded. Does anyone know how to make this work? maybe even without a fwrite?

 

 

Thank you,

 

masterens

 

EDIT: i cannot use mysql

Link to comment
https://forums.phpfreaks.com/topic/206695-earlier-uploaded-files-dont-show/
Share on other sites

  • 1 month later...

working! if anyone wants to know:

 

page load:

$readhandle=fopen("uploaddb.log","r");
    $aotf=fread($readhandle,filesize("uploaddb.log"));
    fclose($readhandle);

 

upload succesful:

	    $writehandle=fopen("uploaddb.log","w");
    fwrite($writehandle,"$aotf\r\n" . "uploadform/gebruikers/" . $naam);
    fclose($writehandle);

 

loading last uploads:

$aotf=explode("\r\n",$aotf);
for($i = count($aotf) - 5; $i <= count($aotf); $i++) {
echo ' <img src="'. $aotf[$i-1] . '" width="128" height="128"> ';
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.