File Download with From date and To date
Posted: Tue Oct 20, 2009 2:08 am
Hi,
Ii have stuck up with one coding. I want to downloads the file From particular folder. It is in this format name-dateandtime.format
Examples : voicefile-2009-10-14.doc or 5101-2009-10-14.gsm
I can able to get file download for particular date. But how can i get from particular date to some date
Example : From date : 2009-10-14
To date : 2009-10-20
I want to get data or file to be downloaded for these dates. How i can i able to get it for particular dates.
can any one assist me with some sample code or some examples for this process.
My code: (For particular date)
<?php
include("conn.php");
$vpath = "/var/lib/";
?>
<form method=post action='<?php $_SERVER[PHP_SELF] ?>' name="form" onsubmit =validateForm();>
<center>
<table cellpadding="0" cellspacing="0" border="0">
<!--<tr><td>Phone Number:</td><td><input type="text" name="campaign" value="" /></td>
<td><input type="submit" name="search1" value="Search" class="butt" /></td></tr>-->
<tr valign="top"><td valign="middle">Date:</td>
<td><input type="Text" id="demo2" name ="phone_no" > <a href="javascript:NewCal('demo2','ddmmyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date" align="top"></a></td></tr><br/>
<tr>
<td></td>
<td align="center"><input type="submit" name="search3" value="Search" class="butt" /></td>
</tr>
</table>
</center>
</form>
<?
$campaign=$_POST['campaign'];
$phone = $_POST['phone_no'];
$agentid=$_POST['agentid'];
$submit3 = $_POST['search3'];
if($submit3 && $phone){
if ($handle = opendir($vpath)) {
echo "<DIV id='layout1'><center><table cellspacing=0 cellpadding=0 border=5 id='thetable'>
Voice File Status For - ". $phone."
<tr><th class='th'>Date</th><th class='th'>Filename</th><th class='th'>Download</th></tr>";
$i=0;
while (false !== ($file1 = readdir($handle)))
{
$file = explode(".",$file1);
//$atime = date("d-m-Y", filemtime($file[0]));
$fname =$vpath.$file1;
$atime = date("d-m-Y", filemtime($fname));
//echo $atime;
if($atime==$phone)
{
echo "<tr align=center><td>$atime</td><td>$file1</td><td align='center'><a href='download.php?path=$vpath&file=$file1'><img src='images/pointer_down.gif' border=0></a></td></tr>";
}
$i++;
}
echo "</table></center></DIV>";
closedir($handle);
}
}
?>
[/b]
Ii have stuck up with one coding. I want to downloads the file From particular folder. It is in this format name-dateandtime.format
Examples : voicefile-2009-10-14.doc or 5101-2009-10-14.gsm
I can able to get file download for particular date. But how can i get from particular date to some date
Example : From date : 2009-10-14
To date : 2009-10-20
I want to get data or file to be downloaded for these dates. How i can i able to get it for particular dates.
can any one assist me with some sample code or some examples for this process.
My code: (For particular date)
<?php
include("conn.php");
$vpath = "/var/lib/";
?>
<form method=post action='<?php $_SERVER[PHP_SELF] ?>' name="form" onsubmit =validateForm();>
<center>
<table cellpadding="0" cellspacing="0" border="0">
<!--<tr><td>Phone Number:</td><td><input type="text" name="campaign" value="" /></td>
<td><input type="submit" name="search1" value="Search" class="butt" /></td></tr>-->
<tr valign="top"><td valign="middle">Date:</td>
<td><input type="Text" id="demo2" name ="phone_no" > <a href="javascript:NewCal('demo2','ddmmyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date" align="top"></a></td></tr><br/>
<tr>
<td></td>
<td align="center"><input type="submit" name="search3" value="Search" class="butt" /></td>
</tr>
</table>
</center>
</form>
<?
$campaign=$_POST['campaign'];
$phone = $_POST['phone_no'];
$agentid=$_POST['agentid'];
$submit3 = $_POST['search3'];
if($submit3 && $phone){
if ($handle = opendir($vpath)) {
echo "<DIV id='layout1'><center><table cellspacing=0 cellpadding=0 border=5 id='thetable'>
Voice File Status For - ". $phone."
<tr><th class='th'>Date</th><th class='th'>Filename</th><th class='th'>Download</th></tr>";
$i=0;
while (false !== ($file1 = readdir($handle)))
{
$file = explode(".",$file1);
//$atime = date("d-m-Y", filemtime($file[0]));
$fname =$vpath.$file1;
$atime = date("d-m-Y", filemtime($fname));
//echo $atime;
if($atime==$phone)
{
echo "<tr align=center><td>$atime</td><td>$file1</td><td align='center'><a href='download.php?path=$vpath&file=$file1'><img src='images/pointer_down.gif' border=0></a></td></tr>";
}
$i++;
}
echo "</table></center></DIV>";
closedir($handle);
}
}
?>
[/b]