Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $path_part = pathinfo($_POST['file']);
- if (isset($_POST['uploadFile'])) {
- $result = count($file);
- for ($i=0; $i<$result; $i++) {
- if ((($path_part['extension'] == "php") || ($path_part['extension'] == "txt")) && ($_FILES["file"]["size"] < 100000)) // 20000
- {
- if ($_FILES["file"]["error"] > 0)
- {
- echo "There was an error uploading your file. <br />";
- }
- else
- {
- echo "Upload: " . $_FILES["file"]["name"] . "<br />";
- echo "Type: " . $_FILES["file"]["type"] . "<br />";
- echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
- if (file_exists("users/" . $_SESSION['user'] . "/uploads/" . $_FILES["file"]["name"]))
- {
- echo $_FILES["file"]["name"] . " already exists. ";
- }
- else
- {
- move_uploaded_file($_FILES["file"]["tmp_name"],
- "users/" . $_SESSION['user'] . "/uploads/" . $_FILES["file"]["name"]);
- echo "This file was successfully uploaded.";
- }
- }
- }
- else
- {
- $invalidFile = true;
- }
- }
- }
- if (isset($invalidFile)) {echo "<div class='errors'>Invalid file type.</div>"; }
- ?>
- <p>Upload your files here:</p>
- <form action="" method="post"
- enctype="multipart/form-data">
- <label for="file">Filename:</label>
- <input type="file" name="file" id="file" /><br />
- <br />
- <input type="submit" name="uploadFile" value="Upload my Files" />
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement