Jump to content


Photo

Redirect to File on Networked Drive


  • Please log in to reply
1 reply to this topic

#1 rustycanuck

rustycanuck
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 08 May 2006 - 03:10 AM

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);
exit;
}
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.

Thanks,
Jay

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 08 May 2006 - 03:55 AM

You need to give them an address relative to your server. You cant simply redirect to a directory where there is no server running.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users