Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Main page.
- <?php
- mb_internal_encoding('utf-8');
- define('TITLE','File upload');
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <style>
- #add {
- height:50px;
- width:250px;
- float:right;
- }
- form {
- width:500px;
- }
- </style>
- <title><?php echo TITLE; ?></title>
- </head>
- <body>
- <?php
- //file upload on main page
- if (isset($_POST['name'])) {
- move_uploaded_file($_FILES['file']['tmp_name'],'add_article_form.php' . $_POST['name'] . '.txt');
- echo 'file uploaded: ' . $_POST['name'] . '.txt';
- }
- echo '<br>' ;
- echo '<br>' ;
- ?>
- <form action = "add_article_form.php" method = "POST">
- <input id = "add" type = "submit" value="Upload">
- </form>
- <h2>Files</h2>
- <?php
- //display file name
- $resource = opendir('../uploads/');
- while(($entry = readdir($resource))!== FALSE)
- {
- if($entry != '.' && $entry != '..'){
- echo "<a href = \"#\">$entry</a>" . '<br>';
- } else {
- "<a href = \"#\">$entry</a>" . '<br>';
- }
- }
- echo '<br>';
- ?>
- </body>
- </html>
- PAGE #2///////////////////////////////////////////////////////////////////////////////////////////////
- <?php
- mb_internal_encoding('utf-8');
- define('TITLE','Добавить статью');
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- #add
- {
- height:50px;
- width:250px;
- }
- </style>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title><?php echo TITLE; ?></title>
- </head>
- <body>
- <!--The upload form, second page -->
- <form action = "../uploads/" method="POST" enctype="multipart/form-data" >
- Название статьи: <br>
- <input type = "text" name = "name" value = "text"><br><br>
- Файл:<br>
- <input type = "file" name="file"><br><br>
- <input id = "add" type = "submit" value="add"><br><br>
- </form>
- <p><a href = "index.php">Back</a></p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement