Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <form action="" method="post"
- enctype="multipart/form-data">
- <label for="file">Filename:</label>
- <input type="file" name="file[]" id="file" /><br>
- <label for="file">Filename:</label><input type="file" name="file[]" id="file" /><br>
- <label for="file">Filename:</label><input type="file" name="file[]" id="file" /><p>
- <label for="select"></label>
- Please select a folder destination:
- <select name="select" id="select">
- <option value="default" selected>Default</option>
- <option value="docs">My Documents</option>
- <option value="music">My Music</option>
- <option value="private">Private</option>
- <option value="public">Public</option>
- <option value="videos">My Videos</option>
- </select>
- <p>
- <input type="submit" name="submit" value="Submit" />
- </form>
- </body>
- </html>
- <?php
- if(isset($_POST['submit'])) {
- $folderDestination = $_POST['select'];
- $ext = end(explode('.', $_FILES["file"]["name"]));
- $filesCount = count($file);
- for ($i = 0; $i<$filesCount; $i++) {
- if ($ext != "exe") // $_FILES["file"]["size"] < 20000
- {
- if ($_FILES["file"]["error"] > 0)
- {
- echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
- }
- else
- {
- echo "Upload: " . $_FILES["file"]["name"] . "<br />";
- echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
- }
- }
- }
- // If the folder is not in the default position, we must place it in the right spot
- for ($i = 0; $i<$filesCount; $i++) {
- if($folderDestination!="default") {
- if (file_exists("users/" . $_SESSION['user'] . "/uploads/" . $folderDestination . "/" . $_FILES["file"]["name"][$i]))
- {
- echo $_FILES["file"]["name"][$i] . " already exists.<br>";
- }
- else
- {
- move_uploaded_file($_FILES["file"]["tmp_name"][$i],
- "users/" . $_SESSION['user'] . "/uploads/" . $folderDestination . "/" . $_FILES["file"]["name"][$i]);
- echo "Your file has been successfully uploaded, and you can now view it right away!";
- }
- } else { // If else, we put it in the uploads folder
- if (file_exists("users/" . $_SESSION['user'] . "/uploads/" . $_FILES["file"]["name"][$i]))
- {
- echo $_FILES["file"]["name"][$i] . " already exists.<br>";
- } else {
- move_uploaded_file($_FILES["file"]["tmp_name"][$i],
- "users/" . $_SESSION['user'] . "/uploads/" . $_FILES["file"]["name"][$i]);
- echo "Your file has been successfully uploaded, and you can now view it right away!";
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement