Jump to content


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


Redirect to File on Networked Drive

Recommended Posts

Hello all,

I'm fairly new to PHP (hence, the post in Newbie Help), and I'm stuck on how to accomplish a particular redirect.

I'm trying to view a PDF file, based on an entry by a user. The PHP file is on a local intranet, and the file is located on a networked drive.

The user enters an Item # and then a PDF file containing the Vendor information for that Item is displayed.

The files are in location: \\serv_1\vendors\ven_info\
The files are all named like [Item #]_vend.pdf (ie. 123456_vend.pdf).

The code I've written is as follows:

$item_num = $_POST['item_num'];
if (is_numeric($item_num) && strlen($item_num) == 6) {

$default_filepath = "\\serv_1\vendors\ven_info\";
$default_ext = "_vend.pdf";
$filename = $default_filepath . $item_num . $default_ext;

if (file_exists($filename)) {
header("Location: " . $filename);
else {
$msg = "No Vendor Info can be found for Item # " . $item_num;
else {
$msg = "Item Number must be 6-digit number.";

When I try to run the code, the file_exists function works (ie. it can tell if the file exists or not). But when I try to redirect to the PDF file, I get an error saying "Cannot find server".

Is there any way I can get the PDF file to open using a header function, or do I need to use something else? Is the problem caused by the location I'm trying to redirect to? Maybe I can't user \\servername\folder format?

Any help is appreciated.


Share this post

Link to post
Share on other sites
You need to give them an address relative to your server. You cant simply redirect to a directory where there is no server running.

Share this post

Link to post
Share on other sites


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.