Author Topic: Save as dialog using php/or html to fwrite in user choise  (Read 277 times)

m1ke4fun

  • New Member
  • *
  • Posts: 9
  • Karma: 0
    • View Profile
Save as dialog using php/or html to fwrite in user choise
« on: June 01, 2012, 05:08:02 AM »
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

  • Technocentror
  • Senior Member
  • ****
  • Posts: 150
  • Karma: 4
  • That is not dead which can eternal loop...
    • View Profile
Re: Save as dialog using php/or html to fwrite in user choise
« Reply #1 on: June 04, 2012, 09:56:36 AM »
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: [Select]

<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>

And in the file 'getFilename.php' you do:
PHP Code: [Select]

<?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";    
}
?>


Does that help?
Good luck,

O.
T.A.N.S.T.A.A.F.L.
_______________________________/

m1ke4fun

  • New Member
  • *
  • Posts: 9
  • Karma: 0
    • View Profile
Re: Save as dialog using php/or html to fwrite in user choise
« Reply #2 on: June 04, 2012, 10:27:58 AM »
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