Change redirect

This commit is contained in:
Senad Uka
2020-06-10 19:48:49 +02:00
parent 496c0ac420
commit a6c3cd3179

View File

@@ -1,6 +1,6 @@
<?php <?php
function hashedName(){ function hashedName() {
$now = time(); $now = time();
$somenumber = rand(); $somenumber = rand();
return sha1("ojhaa $now $somenumber ojhaaa"); return sha1("ojhaa $now $somenumber ojhaaa");
@@ -9,7 +9,8 @@ function hashedName(){
$target_dir = __DIR__ . "/../slike/"; $target_dir = __DIR__ . "/../slike/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
$target_file = $target_dir . hashedName() . ".$imageFileType"; $hashed_name = hashedName();
$target_file = $target_dir . $hashed_name . ".$imageFileType";
$uploadOk = 1; $uploadOk = 1;
@@ -49,7 +50,7 @@ if ($uploadOk == 0) {
// if everything is ok, try to upload file // if everything is ok, try to upload file
} else { } else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
header('Location: B.php'); header("Location: prikazi.php?slika=$hashed_name");
exit(); exit();
} else { } else {
echo "Sorry, there was an error uploading your file."; echo "Sorry, there was an error uploading your file.";