Fix error when no file have been uploaded yet
This commit is contained in:
parent
20a7eeb659
commit
b63e2b61ec
@ -4,5 +4,5 @@ You need to set the `FLAG` environment variable for this challenge to work!
|
||||
|
||||
## Run the image
|
||||
```bash
|
||||
docker run --rm --name unsafe_login --env FLAG='FLAG{UNSAFEGALLERY}' -p 3565:80 -it pierre42100/gns3-appliance-unsafe-gallery
|
||||
docker run --rm --name unsafe_login --env FLAG='FLAG{UNSAFEGALLERY}' -p 3568:80 -it pierre42100/gns3-appliance-unsafe-gallery
|
||||
```
|
@ -15,8 +15,7 @@ if (isset($_FILES["file"])) {
|
||||
// Create target directory
|
||||
if (!is_dir(UPLOAD_DIR) && !mkdir(UPLOAD_DIR, 0770, true)) {
|
||||
$error = "Failed to create storage directory!";
|
||||
}
|
||||
else if ($_FILES["file"]["size"] > 10000) {
|
||||
} else if ($_FILES["file"]["size"] > 10000) {
|
||||
$error = "File is too large!";
|
||||
} else if (move_uploaded_file($_FILES["file"]["tmp_name"], UPLOAD_DIR . "/" . $dest_file_name)) {
|
||||
$success = "The file was successfully uploaded!";
|
||||
@ -76,15 +75,21 @@ if (isset($_FILES["file"])) {
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
if (is_dir(UPLOAD_DIR)) {
|
||||
?>
|
||||
<h2 style="margin-top: 50px;">Your files</h2>
|
||||
<ul>
|
||||
<?php
|
||||
foreach (scandir(UPLOAD_DIR) as $f) {
|
||||
if($f === "." or $f === "..") continue;
|
||||
if ($f === "." or $f === "..")
|
||||
continue;
|
||||
echo "<li><a href='uploads/" . $_SESSION['id'] . "/$f' target='_blank'>" . $f . "</a></li>";
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</ul><?php
|
||||
}
|
||||
?>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user