Reputation: 3657
need a small basic help, I am creating a XML file on the fly using the parameters submitted in the form by the user. Once the form is submitted, I am jumping into PHP code and there I wanted to give a href link to Download/Display the created XML file.
This is my example code:
<?php
$outputForm = 1;
if(isset($_POST['submit'])){
$outputForm = 0
//Function to generate XML file which works as expected, so that XML file is there
createXML($folderPath, $albumName, $dateOfEntry);
//My XML file is named as albumName.xml and stored in the folderPath as specified
echo '<a href = "' . $folderPath . $albumName. '.xml' . '">XML FILE</a>';
}
else{
$outputForm = 1;
}
if($outputForm == 1)
{
//Here follows my input form
<?php
}
?>
FYI:
$folderPath = 'c:/htdocs/output/';
Therefore:
$folderPath . $albumName = 'c:/htdocs/output/jessi';
In this example xml file name:
jessi.xml
I can see the href link in the output but it does nothing when I click on it. I can also see the fullpath to the xml file when I move my cursor over the 'XML FILE' link.
Any ideas how I can embed a href link in the php script to either Download/Display the XML file.
Thanks
Upvotes: 0
Views: 2161
Reputation: 1299
Issue is, you are running your code by accessing to it using http protocol (whether on your local server or remote) and the file you are trying to access is local and you are accessing your local xml file using File URI Scheme So, browser is restricting you to access that file, maybe for some security reason. If you try to access a file by opening a html file directly in browser (not by running it from your localhost) you will be able to access that file location using that link, browser won't restrict you. But you won't be able to execute the php code.
So, You can use relative path or reference to file from your localhost's relative path, use http URI scheme for this and browser won't restrict you from opening a local file.
Upvotes: 0