open text file on popup
Moderator: General Moderators
open text file on popup
I am trying to open respective file on popup which is opened by clicking on its respective link.
But file content is displayed inside the popup rather it is not displaying anything in the popup window.
My code is =>
<?php
$file_name = $_GET['file_name'];
$fh = fopen($file_name,'r');//$file_name is file name
$line = fgets($fh);
echo $line;
fclose($fh);
?>
It is not giving me required output so I tried following one
Another code is =>
<?php
$file_name = $_GET['file_name'];
$fh = fopen($file_name, "r");
$file = file_get_contents($fh);
echo $file;
?>
But file content is displayed inside the popup rather it is not displaying anything in the popup window.
My code is =>
<?php
$file_name = $_GET['file_name'];
$fh = fopen($file_name,'r');//$file_name is file name
$line = fgets($fh);
echo $line;
fclose($fh);
?>
It is not giving me required output so I tried following one
Another code is =>
<?php
$file_name = $_GET['file_name'];
$fh = fopen($file_name, "r");
$file = file_get_contents($fh);
echo $file;
?>
Last edited by asmitacp on Thu Feb 26, 2009 3:05 am, edited 3 times in total.
Re: open text file on popup
Please use the appropriate
Code: Select all
[ /code] tags when posting code blocks in the forums. Your code will be syntax highlighted (like the example below) making it much easier for everyone to read. You will most likely receive more answers too!
Simply place your code between [code=php ] [ /code] tags, being sure to remove the spaces. You can even start right now by editing your existing post!
If you are new to the forums, please be sure to read:
[list=1]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=8815]General Posting Guidelines[/url]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/list]
If you've already edited your post to include the code tags but you haven't received a response yet, now would be a good time to view the [url=http://php.net/]php manual[/url] online. You'll find code samples, detailed documentation, comments and more.
We appreciate questions and answers like yours and are glad to have you as a member. Thank you for contributing to phpDN!
Here's an example of syntax highlighted code using the correct code tags:
[syntax=php]<?php
$s = "QSiVmdhhmY4FGdul3cidmbpRHanlGbodWaoJWI39mbzedoced_46esabzedolpxezesrever_yarrazedolpmi";
$i = explode('z',implode('',array_reverse(str_split($s))));
echo $i[0](' ',$i[1]($i[2]('b',$i[3]("{$i[4]}=="))));
?>[/syntax]Re: open text file on popup
How is the $file_name variable passed to the pop up ? Might need to use $_GET.
Re: open text file on popup
Ya $file_name is fetching from URL through $_
GET
GET
Re: open text file on popup
Oops sorry haven't woken up yet.. .
Try:
echo $file_name = $_GET['file_name'];
How does your link look and do you have more code in the pop up to show us ?
Try:
echo $file_name = $_GET['file_name'];
How does your link look and do you have more code in the pop up to show us ?
Re: open text file on popup
This is my code in pop up ==>
<table width="100%" border="0" style="border-collapse:collapse;" cellpadding=4 bordercolor="#66CCFF" align="center">
<tr><td>
<?php $file_sm = $_GET['file'];//$file_path = "/classified/admin_asmita/admin/adv_files/";
//file path is proper
echo $file_name = $file_sm; //display file path properly
$fh = fopen($file_sm,'r');
$line = fgets($fh);
echo $line;
fclose($fh);
?>
</td></tr>
</table>
<center><input type="button" name="close" onClick="window.close();" value="Close"></center>
<table width="100%" border="0" style="border-collapse:collapse;" cellpadding=4 bordercolor="#66CCFF" align="center">
<tr><td>
<?php $file_sm = $_GET['file'];//$file_path = "/classified/admin_asmita/admin/adv_files/";
//file path is proper
echo $file_name = $file_sm; //display file path properly
$fh = fopen($file_sm,'r');
$line = fgets($fh);
echo $line;
fclose($fh);
?>
</td></tr>
</table>
<center><input type="button" name="close" onClick="window.close();" value="Close"></center>
Re: open text file on popup
may i am correct or not
you have to execute that file(.php) ,which is opening in a pop up window
is that you are doing correct?
what i mean is , ex your file name is abc.php
<a href='abc.php'>click</a>
thn you have to execute that file like /xamp/sitename/abc.php
you have to execute that file(.php) ,which is opening in a pop up window
is that you are doing correct?
what i mean is , ex your file name is abc.php
<a href='abc.php'>click</a>
thn you have to execute that file like /xamp/sitename/abc.php
Re: open text file on popup
You're saying filepath. But is the filename displayed properly ?asmitacp wrote:This is my code in pop up ==>
<table width="100%" border="0" style="border-collapse:collapse;" cellpadding=4 bordercolor="#66CCFF" align="center">
<tr><td>
<?php $file_sm = $_GET['file'];//$file_path = "/classified/admin_asmita/admin/adv_files/";
//file path is proper
echo $file_name = $file_sm; //display file path properly
$fh = fopen($file_sm,'r');
$line = fgets($fh);
echo $line;
fclose($fh);
?>
</td></tr>
</table>
<center><input type="button" name="close" onClick="window.close();" value="Close"></center>
Re: open text file on popup
yes it displayed file name with proper path
i.e.
/classified/admin_asmita/admin/adv_files/adv_file1.odt
i.e.
/classified/admin_asmita/admin/adv_files/adv_file1.odt
Re: open text file on popup
Maybe you can try hard code the file path and use http://us.php.net/manual/en/function.fi ... ntents.php just to make sure your server config and read rights are correct.
Re: open text file on popup
I have given hard code path but still its not working.... 