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 !