Jump to content

wladkov

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

wladkov's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Okay guys, i added some things etc. I have a favor could you check those both codes and tell me what you think about them. How could or should i improve them? <html> <head> <title> File Delete </title> </head> <body bgcolor="black" text="red"> <center><pre><h2> > . file delete . < </pre></h2> <form method="post" action=""> <textarea name="delete">Delete File </textarea> <br /> <pre>Are you sure? </pre><br /> <input type="submit" value="Yes"> <input type="reset" value="No"> </form></center> </body> </html> <?php $filedelete = $_POST['delete']; function delete_file($filedelete){ if(!isset($_POST['delete'])) exit; unlink($_POST['delete']) or die("<pre>File couldn't be deleted.</pre>"); } delete_file($fieledelete); if (delete_file==true) { echo "<pre>File has been deleted.</pre>"; } ?> I know that if you execute this code without proper name it will show en error of Warning: unlink().... and then print "File couldnt be deleted"; How could i fix that? And is my if statment correct? Also here is the second code: <html> <head> <title>File Saver</title> </head> <body bgcolor="black" text="red"> <center><pre><h2> > . file saver . < </pre></h2> <form method="post" action=""> <textarea name="nazwa">Name Of File</textarea> <br /> <textarea name="source" cols="35" rows="20">Enter text</textarea> <br /> <input type="submit" value="Create"> </form></center> <?php //variables $filename = $_POST['nazwa']; $filesource = stripslashes($_POST['source']); //function create the file function create_file($filename, $filesource){ if(!isset($_POST['nazwa'])) exit; $fileh = fopen($filename, 'w+') or die("<pre>>>Cannot create a file.</pre>"); fwrite($fileh, $filesource); fclose($fileh); //uncoment to use chmods chmod("$filename", 0777); } //use the function if (create_file==true){ create_file($filename, $filesource); echo "<pre>>>File(s) that have been created: <br /><br /></pre>"; echo '<a href='.$filename.'>'.$filename.'<a/>'; } ?> What you think is everything looks correct? How could i use loops to allow me put more than 1 file at the time and give him a name? == THANKS !!!!
  2. Could you show me like an example? With loops and saving many files at once?
  3. Hello Everyone. Im in the progress of creating a script that will create multiplay files at once, the script wiill do those things: Will get the name of the file. WIll get the source of the file. Will put 777 chmods on it. And it will save everything. Ok so here's my code and my problems: <html> <body> <head> <title>Random File Saver</title> </head> <form method="post" action=""> <textarea name="nazwa">Name Of File</textarea> <br /> <textarea name="source" cols="40" rows="20">Enter text</textarea> <br /> <input type="submit" value="Create"> </form> <?php //variables $filename = $_POST['nazwa']; $filesource = stripslashes($_POST['source']); //function create the file function create_file($filename, $filesource){ $fileh = fopen($filename, 'w+') or die("Cannot create a file"); fwrite($fileh, $filesource); fclose($fileh); chmod("$filename", 0777); } //use the function create_file($filename, $filesource); //if statment if (create_file==true){ echo "<pre>File(s) that have been created: <br /><br /></pre>"; echo $filename; } ?> 1. How can i prevent message "Cannot create a file" to show whenever the code is executed. Meaning it shows when i execute it once, then when i put the name and source there is no problem. 2. If you look at the last line, only the file name will print, is there a way that the user will be able to click on that file? Like in html using href option. Meaning i want some option that will read the file name from $_POST['nazwa'] and then it will allow the user to click on it. 3. Is there a way that i can upload many files at once? Like 5 files at once, or something and you can save each one with different name and source? Okay , that would be all. Thank you !
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.