Afisare mesaj si refresh la upload in php
Scris: Vin Sep 23, 2016
Salutare,
Am urmatorul cod care imi face upload de fisiere in server, insa nu stiu cum sa fac ca atunci cand fisierul este urcat pe server sa imi arata un mesaj: "Fisier uploadat cu succes"
Codul din index.php
si codul pentru upload_file.php
Linia de cod: echo "Successfully inserted"; nu functioneaza dupa ce se face upload-ul.
Multumesc!
Am urmatorul cod care imi face upload de fisiere in server, insa nu stiu cum sa fac ca atunci cand fisierul este urcat pe server sa imi arata un mesaj: "Fisier uploadat cu succes"
Codul din index.php
Cod: Selectaţi tot
<form action="upload_file.php" method="post" enctype="multipart/form-data" name="upload_file" autocomplete="off"><br>
<label for="UploadFileField"></label><br>
<input type="file" name="UploadFileField"/>
<input type="submit" name="UploadButton" value="Upload" />
</form>
Cod: Selectaţi tot
<?php
if (isset ($_FILES['UploadFileField'])){
$UploadName = $_FILES['UploadFileField'] ['name'];
$UploadName = mt_rand (100000, 999999).$UploadName;
$UploadTmp = $_FILES['UploadFileField'] ['tmp_name'];
$UploadType = $_FILES['UploadFileField'] ['type'];
$FileSize = $_FILES['UploadFileField'] ['size'];
$UploadName = preg_replace("#[^a-z0-9.]#i", "", $UploadName);
if(($FileSize > 1250000)){
die ("Error - File to big");
}
if(!$UploadTmp) {
die ("No File Selected");
}
else {
if (move_uploaded_file($UploadTmp, "Upload/$UploadName")) {
echo "Successfully inserted";
header('Location: /index.php');
}
else {
echo "Something went wrong";
header('Location: /index.php');
}
}
}
?>
Multumesc!