Now I am using php and mysql so not sure if this should be in the php section.

If you can help I would be most greatful.
I am trying to create a search page so that it shows data and one of the columns in the mysql database contains links to a file for the particular record of a person which is stored on the webserver but when I click on the link it cannot find the file. so any help you can give about linking to files locally stored on a webserver so that you can click and open them would be helpful. This is part of my code which includes the linking to the file. I put in bold the areas of code which are directly to do with the link.

while($row = mysql_fetch_assoc($searchtattoo))
	{
	$uniqueT = $row['unique_number'];
	$fnameT = $row['first_name'];
	$snameT = $row['surname'];
	$treattot = $row['total treatments'];
	$treatcom = $row['treatments_completed'];
	$ampay = $row['amount_paid'];
	[B]$filelink = $row['file_link'];[/B]
	
	echo "<table cell padding=3 border=1 align=center> 
	<tr>
	<td> Unique Number </td><td>Firstname </td> <td>Surname</td> <td>total  number of treatments</td><td>number of treatments had</td> <td>amount paid in pounds</td><td>File Link </td> 
	</tr>
	<tr>
	<td>$uniqueT </td> <td> $fnameT </td> <td> $snameT </td> <td> $treattot </td> </td> <td> $treatcom </td> <td> $ampay </td> <td>[B]<a href=".$filelink.">".$filelink." </a>[/B]
	</tr>
	</table>
	";
	}

The file location as stored in my database is
T1002victoriadeboer.tiff

The filelocation as on the USB drive I am working on is

F:\xampp\htdocs\laserclearsearch\Tattoo\laserclearsearch\Tattoo\T1002victoriadeboer\T1002victoriadeboer.tiff

Member Avatar for diafol

Sorry for my confusion. Are you trying to access a local file from a webserver? This memory stick, dependent on the PC you are using could have a different path. Usually files are accessed from a webserver once they've been uploaded. Can't say much more than that. I would imagine that your solution would be a massive security risk. Open a file on an user's local filesystem and fiddle with it! Yikes!! How about some windows system files? I'd have a freak!

Sorry for my confusion. Are you trying to access a local file from a webserver? This memory stick, dependent on the PC you are using could have a different path. Usually files are accessed from a webserver once they've been uploaded. Can't say much more than that. I would imagine that your solution would be a massive security risk. Open a file on an user's local filesystem and fiddle with it! Yikes!! How about some windows system files? I'd have a freak!

I am trying to access a file on the webserver. What I have done is installed XAMPP on a USB external harddrive. I have stored a load of digital images in a folder called tattoo in the htdocs folder. I am creating a mini system to be used in a clinic which is NOT out on the internet for searching records which are on the USB external harddrive. So really the idea is a unique ID is entered eg T0001 and brings up a table with that record and one of the fields in the record is a link to a digital copy of paper files about that particular person.

Does that make sense? anymore questions then please ask.

Member Avatar for diafol

OK now I get you. You can do this:

$filelocation = "/laserclearsearch/Tattoo/laserclearsearch/Tattoo/T1002victoriadeboer/"; //absolute ref - this can be set in an include file if you need this value for loads of pages. You could even set it up as a constant, using define().

$file = (whatever get it from DB);

$filelink = $filelocation . $file; 

....

<a href=".$filelink.">".$filelink." </a>

....
etc.

Thanks for the help. The problem is now solved. In looking at what you suggested I found out what the problem was. The file extension in the database was wrong by one character. Instead of .tif I had .tiff which was stopping the file location being found.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.