href=path doesn't work

Hi guys,

This application is to open a picture file that is on a network, it was working good in Php 4 but now, I'm using PHP 5.4 and doesn't wotk.
The application find the picture file then displays the link but when I click it, it doesn't do anything even no errors.

This is the code:

<?PHP
if(isset($_POST['submit'])<wbr ></wbr>) {
	if($_POST['dian']==''){
		echo('<div align="center" class="style23"><font name="arial">El día de nacimiento es indispensable para la búsqueda!</font></div>');
		exit(); }
	if($_POST['mesn']==''){
		echo('<div align="center" class="style23"><font name="arial">El mes de nacimiento es indispensable para la búsqueda!</font></div>');
		exit(); }
	if($_POST['anon']==''){
		echo('<div align="center" class="style23"><font name="arial">El año de nacimiento es indispensable para la búsqueda!</font></div>');
		exit(); }
	if($_POST['letra']==''){
		echo('<div align="center" class="style23"><font name="arial">La primer letra del apellido paterno es indispensable!</font></div<wbr ></wbr>>');
		exit(); }
	if($_POST['mesp']==''){
		echo('<div align="center" class="style23"><font name="arial">El mes de proceso es indispensable para la búsqueda!</font></div>');
		exit(); }
	if($_POST['anop']==''){
		echo('<div align="center" class="style23"><font name="arial">El año de proceso es indispensable para la búsqueda!</font></div>');
		exit(); }
	$letra = strtoupper($_POST['letra']<wbr ></wbr>);
	$dian = $_POST['dian'];
	$mesn = $_POST['mesn'];
	$mesp = $_POST['mesp'];
	$anop = $_POST['anop'];
	$anon = $_POST['anon'];
	$dian = sprintf("%02d", $dian);
	$mesn = sprintf("%02d", $mesn);
	$mesp = intval($mesp);
	$root = '//192.168.xxx.xxx/Volume_1/<wbr ></wbr>FOTOS_MCAS<wbr ></wbr>/';
	$searchin = "$anop/$mesp/";
	$birthday = $anon.$mesn.$dian;
	$fullpath = $root.$searchin;
	$archivo  = "$letra*$birthday*";
	$todo = $fullpath.$archivo.".jpg";<wbr ></wbr>
	echo "$todo";
 	$files = glob($todo);
	$hay = "no";
	echo '<ul>';
	foreach ($files as $path) {
    	echo '<a href="file:'.$path.'" target="_blank">'.htmlspec<wbr ></wbr>ialchars(b<wbr ></wbr>asename($p<wbr ></wbr>ath)).'</a<wbr ></wbr>>';
		$hay = "si";
	}
	echo '</ul>';
	if ($hay == "no") {
		echo "ESTA FOTO NO EXISTE!";
	}
}
?>

Open in new window


Hope you guys can help me, thank you so much.
elm9999Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kiran Paul VJComputer EngineerCommented:
Can you post the browser source code as well? Do you have the correct href attribute value in a tag?
0
elm9999Author Commented:
Yes it is the correct value
<HTML>
<style type="text/css">
	.style2 {font-family: Arial, Helvetica, sans-serif}
	.style6 {font-size: 9px}
	.style8 {font-size: 14px}
	.style9 {font-size: 16px}
	.style10 {font-family: Arial, Helvetica, sans-serif; font-size: 16px; }
	.style14 {font-size: 16}
	.style15 {font-family: Arial, Helvetica, sans-serif; font-size: 14px; }
	.style16 {font-family: Arial, Helvetica, sans-serif; color: #0000FF; }
	.style20 {
	font-size: 12px;
	color: #CC0000;
}
	.style22 {color: #0033FF}
.style57 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 16px;
	font-weight: bold;
	color: #FF0033;
}
.style58 {
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
	font-style: italic;
	font-size: 18px;
	color: #330066;
}
.style68 {
	color: #005300;
	font-weight: bold;
	font-style: italic;
}
.style69 {font-size: 12px}
.style73 {color: #CA0000; font-family: Arial, Helvetica, sans-serif; font-size: 14px; }
.style74 {color: #CCCCCC}
.style75 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: #000066;
}
</style>
<BODY bgcolor="#E6E6E6">
<table width="1000" border="0" align="center">
	<tr>
    <td><a href="//intralan/index.php"><img src="//intralan/Imagenes/topbaner.jpg" width="1000" height="88" border="0" align="top"></a></td>
  	</tr>
</table>
<table width="1012" border="0" align="center">
	<tr><td width="1006"><div align="right" class="style22 style8 style2 style16 style15"><em>Informática - López Mejía Emilio</em></div></td></tr>
  	<tr><td><div align="right" class="style15 style16 style2 style8 style22"></div></td></tr>
</table>
<p align="center" class="style58">B&uacute;squeda de fotograf&iacute;as de registros del SIAC </p>
<form action="/Intranet2014/aplicaciones/fotos_siac/busca_fotos.php" method=POST>
  <table width="700" border="1" align="center">
	<tr>
	<td width="238" height="24"><span class="style9"><span class="style10">1&ordm; Letra del Apellido Paterno:</span></span></td>
    <td width="446"><div align="left"><span class="style10"><span class="style9">Letra:
            <input name="letra" type="text" id="letra" size="1" maxlength="1">
    </span> </span></div></td>
    </tr>
	<tr>
	  <td height="24">&nbsp;</td>
	  <td><span class="style74">.</span></td>
    </tr>
	<tr>
	  <td height="24"><span class="style10">Fecha de Nacimiento:</span></td>
	  <td><span class="style10">D&iacute;a:
          <input name="dian" type="text" id="dian" size="2" maxlength="2">
Mes:
<input name="mesn" type="text" id="mesn" size="2" maxlength="2">
A&ntilde;o:
<input name="anon" type="text" id="anon" size="4" maxlength="2"> 
<span class="style20">(DD-MM-AA)</span></span></td>
    </tr>
	<tr>
	<td height="24">&nbsp;</td>
	<td><div align="left" class="style74">.</div></td>
	</tr>
	<tr>
	<td height="26"><span class="style10">Mes y A&ntilde;o de Expedici&oacute;n:</span></td>
	<td><div align="left"><span class="style10">
	    Mes:
          <input name="mesp" type="text" id="mesp" size="2" maxlength="2">
          A&ntilde;o:
          <input name="anop" type="text" id="anop" size="4" maxlength="4">
          <span class="style20">(MM-AAAA)	</span> </span></div></td>
    </tr>
</table>
<p align="center" class="style6"><span class="style10 style14 style2"><span class="style9">
  <input type="submit" name="submit" value="Buscar Foto">
</span></span></p>
<p align="center" class="style6">
  //192.168.8.232/Volume_1/FOTOS_MCAS/2002/8/H*620408*.jpg<ul><a href="file://192.168.8.232/Volume_1/FOTOS_MCAS/2002/8/HEAM620408MDGRDY00.jpg" target="_blank">HEAM620408MDGRDY00.jpg</a></ul></p>
</form>
<p align="center" class="style57">&nbsp;</p>
<table width="397" border="0" align="center">
  <tr>
    <td width="391"><div align="left" class="style15"><span class="style68">Fotos existentes en este sistema:</span></div></td>
  </tr>
  <tr>
    <td><div align="left"><span class="style2"><span class="style69"><span class="style8"></span></span></span></div></td>
  </tr>
  <tr>
    <td><div align="center" class="style73">
      <div align="left">2002 - (de Abril a Diciembre)</div>
    </div></td>
  </tr>
  <tr>
    <td><div align="center" class="style73">
      <div align="left">2003 - (de Enero a Diciembre)</div>
    </div></td>
  </tr>
  <tr>
    <td><div align="center" class="style73">
      <div align="left">2004 - (de Enero a Septiembre y de Noviembre a Diciembre)</div>
    </div></td>
  </tr>
  <tr>
    <td><div align="center" class="style73">
      <div align="left">2005 - (de Enero a Febrero) </div>
    </div></td>
  </tr>
</table>
<hr>
<p align="center" class="style75">Sistema desarrollado en el Consulado General de M&eacute;xico en Los Angeles, CA. @ 2010 - Actualizado en Abril de 2015. </p>
</body>
</html>

Open in new window

0
elm9999Author Commented:
And yes, it has the correct value
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

arnoldCommented:
The issue is that you are searching through

A browser usually will not allow an external web application the option to have the user click and open a local file.

Add in the for each loop a line preceding or following the link so that you can clearly see what the info is.

I think you are placing the restriction on the wrong side, I do not think the issue is with the php code, but the browser that is being used has further security settings deniying the "external" to access local resources.
0
Kiran Paul VJComputer EngineerCommented:
@elm9999 are you able to see new browser tab opening?

Also try in a different browser as some browsers block file:\\ protocol
0
Dave BaldwinFixer of ProblemsCommented:
@arnold is correct, modern browsers will not open a 'file://' url when requested from a page that is loaded with 'http://'.  It is considered a serious security issue.

https://code.google.com/p/browsersec/wiki/Part2

What you can do is fetch the file with PHP on the server and let PHP send the file to the browser.  That avoids the 'file://' request in the browser.
0
elm9999Author Commented:
Thank you guys, No, it does not open a new tab even if I make a right click to open to another window, it does not do anything.

I'll check the link that Dave posted.
0
arnoldCommented:
Create a separate entry with an href=http:// in the same context and see the http:// link will trigger a new window.
Window not opening means the destination specified in href is determined first. There is no need to open a new window when the request that will be passed to it is invalid.

The PHP script is executed through a browser, given the PHP code allows you to list the contents of the directories, as Dave suggested, why not create a set of unique IDs to indicate which file is being requested and have the link refer back to the same script In the example the name could be  href=getmeanimage.php?id=192.168.8.232/Volume_1/FOTOS_MCAS/2002/8/HEAM620408MDGRDY00.jpg
This provides the most flexibility if you have multiple shares where images might be.  If you only have one source, that reference can be reduced.
the getmeanimage.php will then open the file and stream it back as Content-Type: image/jpeg
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
elm9999Author Commented:
Thank you so much every one,

Actually, this app is used a few times per year and I find it a little complicated to change the code so, what I did was after the link appears, I make a right click-copy shortcut-and paste it on another tab, and works great, also before this update, I start to develop another vb.net app.

Thank you so much for your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.