Connecting Tech Pros Worldwide Help | Site Map

View files uploaded through form

Member
 
Join Date: Feb 2008
Posts: 63
#1: Mar 16 '08
Hi,
I have made a registration form for job site in which the user uploads a .doc or .txt file through form along with the other details stored in the database. The uploaded files is sored in the upload folder that i created in working directory and not in the database. Now when someone enters the search page and enters the search criteria the name of the users with that criteria are listed. When i ckick on the name of any user then his details are displayed which he filled during registration. Now i want that the details page that is displayed should also give the user a link to view the file uploaded by that particular user whose details are diaplayed. How can i assign a link to view the uploaded file that is not in the database but in some folder. Can this be done. Plz let me know.
Thanks.
Member
 
Join Date: Feb 2008
Posts: 63
#2: Mar 16 '08

re: View files uploaded through form


The name of the file is stored in the database.
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#3: Mar 16 '08

re: View files uploaded through form


Depends whether you want to download it first to the user and then view it or want to show it to the user directly. You know how to download. For the direct view you can read the file yourself, translate any newlines to <br> and just echo it to the screen.
[php]$file = 'your_textfile_on_server';
$fh = fopen($file, 'r+');
$text = fread($fh, filesize($file));
$text = nl2br(strip_tags($text));
fclose($fh);
echo $text;[/php]Ronald
Reply