last day (15 days later) » 

8:49 AM
2
A: Getting the value of textbox and using it as a filename in PHP

Syed QaribYou need to get the filename set in form and then set it. Just update your php code to this: $file = 'C:\wamp\www\dl\Form2.pdf'; $filename = $_REQUEST['refOff'].'.pdf'; //Get filename set in form if (file_exists($file)) { header('Content-Description: File Transfer'); header('Conten...

 
i did try and there is no file being downloaded. why is that so?
 
try error_reporting to on and see if there are some errors
 
sorry, i am not that good in PHP, i dont know how to do that =(
 
Google it Lady..
 
thank you, I did and it says: Notice: Undefined index: refOff
 
8:49 AM
are you sure you came to download page by submitting the form you showed in the html ?
 
before i changed the code to look like the one you have suggested, I can download the file, but the filename is Form2.pdf
 
I am asking are you coming to download.php page by submit button click in form of your form page ?
'refOff' will be undefined if you access download page directly.. try downloading using the form submit.. as your form had 'refOff' text field.. so it will not get undefined index..
 
9:02 AM
yes. if im clicking the submit button, im being redirected to the download page
but before i changed the code, i am able to download the file
 
9:17 AM
try changing
$filename = $_REQUEST['refOff'].'.pdf';
$filename = $_POST['refOff'].'.pdf';
to
Also, I have updated my answer have a look
and when you are testing .. make sure you come from form page and write something in filename text field and then click submit
 

  last day (15 days later) »