anton_1 Posted March 6, 2012 Share Posted March 6, 2012 Hey guys!, Any help is greatly appreciated! what i want to do is store a link to a pdf file which will open the file when clicked. just now when clicked will only open the file name but not with the extension .pdf? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/258397-best-way-to-store-a-link-to-pdf-in-database/ Share on other sites More sharing options...
Anon-e-mouse Posted March 6, 2012 Share Posted March 6, 2012 Hey guys!, Any help is greatly appreciated! what i want to do is store a link to a pdf file which will open the file when clicked. just now when clicked will only open the file name but not with the extension .pdf? Thanks! Hello, Are you uploading the file? If so, can you post how you are? Sounds like you are saving the filename but not the extension.. Quote Link to comment https://forums.phpfreaks.com/topic/258397-best-way-to-store-a-link-to-pdf-in-database/#findComment-1324522 Share on other sites More sharing options...
anton_1 Posted March 6, 2012 Author Share Posted March 6, 2012 thanks for your reply mate, yes that exactly correct im saving the file name as filename.pdf and the file is stored within the server folder but when I select all form database and click on it, it only goes to http://localhost/pagename/filename whithout the .pdf Quote Link to comment https://forums.phpfreaks.com/topic/258397-best-way-to-store-a-link-to-pdf-in-database/#findComment-1324528 Share on other sites More sharing options...
Anon-e-mouse Posted March 6, 2012 Share Posted March 6, 2012 thanks for your reply mate, yes that exactly correct im saving the file name as filename.pdf and the file is stored within the server folder but when I select all form database and click on it, it only goes to http://localhost/pagename/filename whithout the .pdf Do you have any code that you can post? It's a bit hard to help without seeing what you are actually doing at the moment.. Quote Link to comment https://forums.phpfreaks.com/topic/258397-best-way-to-store-a-link-to-pdf-in-database/#findComment-1324534 Share on other sites More sharing options...
anton_1 Posted March 6, 2012 Author Share Posted March 6, 2012 Yeah mate this retrieves the file and outputs it. after I have clicked the link and it displays in the url. if I add .pdf onto the end it does display the pdf. So even if there was a way to put . ".pdf" after it or something? thanks again! <?php function checkValues($value) { // Use this function on all those values where you want to check for both sql injection and cross site scripting //Trim the value $value = trim($value); // Stripslashes if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // Convert all <, > etc. to normal html and then strip these $value = strtr($value,array_flip(get_html_translation_table(HTML_ENTITIES))); // Strip HTML Tags $value = strip_tags($value); // Quote the value $value = mysql_real_escape_string($value); return $value; } include("dbcon.php"); $rec = checkValues($_REQUEST['val']); //get table contents if($rec) { $sql = "select * from questions where Question like '%$rec%'"; } else { $sql = "select * from questions"; } $rsd = mysql_query($sql); $total = mysql_num_rows($rsd); ?> <?php while ($rows = mysql_fetch_assoc($rsd)) {?> <div class="each_rec"><a href="<?php echo $rows['Question'];?>" target="_blank"><?php echo $rows['HelpDocument'];?></a></div> <?php } if($total==0){ echo '<div class="no-rec">No Record Found !</div>';}?> Quote Link to comment https://forums.phpfreaks.com/topic/258397-best-way-to-store-a-link-to-pdf-in-database/#findComment-1324537 Share on other sites More sharing options...
Anon-e-mouse Posted March 6, 2012 Share Posted March 6, 2012 Next time wrap code in code tags, much easier to read. I was thinking more along the lines of the code you use to upload the file but ultimately save it in your table as that is the part thats missing. If you wanted to amend .pdf you could: <a href="<?php echo $rows['Question'].'.pdf'; ?>" target="_blank"> Should work. Although that then forces you to have each file a PDF. Quote Link to comment https://forums.phpfreaks.com/topic/258397-best-way-to-store-a-link-to-pdf-in-database/#findComment-1324540 Share on other sites More sharing options...
anton_1 Posted March 6, 2012 Author Share Posted March 6, 2012 will try just now thanks! Quote Link to comment https://forums.phpfreaks.com/topic/258397-best-way-to-store-a-link-to-pdf-in-database/#findComment-1324541 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.