homer.favenir Posted September 10, 2009 Share Posted September 10, 2009 hi, i made a link to open a pdf file stored in a folder. but the link isnt working $pdfloc = "file://asecasiagsd/AGS/AGS/WIP/upload/".$pdf; <td height="0" colspan="2"><a href="<?php echo $pdfloc; ?>" target="_blank"><?php echo $pdfloc; ?></a></td> am i doing it right? Quote Link to comment https://forums.phpfreaks.com/topic/173762-link-to-open-pdf-in-new-window/ Share on other sites More sharing options...
Adam Posted September 10, 2009 Share Posted September 10, 2009 Based on just that snippet I can't tell if the problem is that you're not echo'in out the HTML / closing and opening the tags correctly. Or whether you're trying to define a variable without enclosing it in PHP tags. For the former: $pdfloc = "file://asecasiagsd/AGS/AGS/WIP/upload/".$pdf; echo '<td height="0" colspan="2"><a href="' . $pdfloc . '" target="_blank">' . $pdfloc . '</a></td>'; ... and for the latter: <?php $pdfloc = "file://asecasiagsd/AGS/AGS/WIP/upload/".$pdf; ?> <td height="0" colspan="2"><a href="<?php echo $pdfloc; ?>" target="_blank"><?php echo $pdfloc; ?></a></td> Quote Link to comment https://forums.phpfreaks.com/topic/173762-link-to-open-pdf-in-new-window/#findComment-915952 Share on other sites More sharing options...
homer.favenir Posted September 10, 2009 Author Share Posted September 10, 2009 you're trying to define a variable without enclosing it in PHP tags. well, i have a long script, so to make it short i just posted the one that is relevant. ill try this one thanks Quote Link to comment https://forums.phpfreaks.com/topic/173762-link-to-open-pdf-in-new-window/#findComment-915960 Share on other sites More sharing options...
homer.favenir Posted September 11, 2009 Author Share Posted September 11, 2009 its not working! someone please help Quote Link to comment https://forums.phpfreaks.com/topic/173762-link-to-open-pdf-in-new-window/#findComment-916552 Share on other sites More sharing options...
Adam Posted September 11, 2009 Share Posted September 11, 2009 Show the code you have now? Try using a syntax highlighter, they can often point out small syntax errors, especially when it comes to strings. Quote Link to comment https://forums.phpfreaks.com/topic/173762-link-to-open-pdf-in-new-window/#findComment-916556 Share on other sites More sharing options...
homer.favenir Posted September 11, 2009 Author Share Posted September 11, 2009 ok, i made it working now <?php ob_start(); $book = $_GET['book']; $fileExtension = "pdf"; $sourceFile = "\\\\asecasiagsd\\ags\\ags\\wip\\upload\\".$book; $outputFile = $sourceFile; // the name they save as can be different to the existing file // required for IE, otherwise Content-disposition is ignored //if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off'); switch( $fileExtension) { case "pdf": $ctype="application/pdf"; break; case "exe": $ctype="application/octet-stream"; break; case "zip": $ctype="application/zip"; break; case "doc": $ctype="application/msword"; break; case "xls": $ctype="application/vnd.ms-excel"; break; case "ppt": $ctype="application/vnd.ms-powerpoint"; break; case "gif": $ctype="image/gif"; break; case "png": $ctype="image/png"; break; case "jpeg": case "jpg": $ctype="image/jpg"; break; default: $ctype="application/force-download"; } //session_cache_limiter(""); header("Pragma: public"); // required header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); // required for certain browsers header("Content-Type: $ctype"); //header("Content-Disposition: attachment; filename=".basename($outputFile).";" ); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($sourceFile)); echo $sourceFile; readfile("$outputFile") ; // This is the bit that prompts for the download, supress errors for niceness exit(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/173762-link-to-open-pdf-in-new-window/#findComment-916574 Share on other sites More sharing options...
Adam Posted September 11, 2009 Share Posted September 11, 2009 The original code you posted isn't even in that... Quote Link to comment https://forums.phpfreaks.com/topic/173762-link-to-open-pdf-in-new-window/#findComment-916576 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.