PHP Programming > General PHP Help
Save as dialog using php/or html to fwrite in user choise
(1/1)
m1ke4fun:
My doubt is how to open a dialog box(using html/php) to the user so that he can decide where the txt file (which will be created by the php fwrite) will be recorded and under what name.
Ojoshiro:
Hi Mike,
What exactly do you mean with a dialog box?
The regular way to ask something from a user via HTML/PHP is via forms.
--- PHP Code: ---
<form action="getFilename.php" method="post" name="askaname">
Name for the generated file <input type="text" name="filename" value=""/><br/>
<input type="submit" name="submit" value="Send form"/>
</form>
--- End code ---
And in the file 'getFilename.php' you do:
--- PHP Code: ---
<?php
if ( array_key_exists( 'filename', $_POST ) && $_POST['filename'] )
{ $filename = $_POST['filename'];
if ( preg_match( '/\.php$/', $filename ) )
{ echo "Sorry we don't accept '.php' files<br/>\n";
} else
{ // Here you open the file for writing, using the filename
}
} else
{ echo "We need a filename to create this file with<br/>\n";
}
?>
--- End code ---
Does that help?
Good luck,
O.
m1ke4fun:
I appreciate your answer, but my doubts were misplaced and functionality itself has changed.
Thank you for answer anyway, i would ask how delete this topic or how to report moderator to delete this topic.
Thanks,
Michael
Navigation
[0] Message Index
Go to full version