I just try to do a little web for my job to upload videos. The issue is when I upload the file and press the Submit botton, the web browser show me the code of upload.php, not the echo. Here is part of the HTML:
<body>
<header>
<h1>El Renderitzador</h1>
</header>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" value="Penja">
</form>
</div>
</body>
<footer>Tots els drets reservats © RTVCardedeu</footer>
And this is the PHP:
<?php
// RTVC - LA RENDERITZACIO
if(isset($_FILES['file'])) {
$file = $_FILES['file'];
// PROPIETATS DEL FITXER
$file_name = $file['name'];
$file_tmp = $file['tmp_name'];
$file_size = $file['size'];
$file_error = $file['error'];
// EXTENSIO
$file_ext = explode('.', $file_name);
$file_ext = strtolower(end($file_ext));
$allowed = array('txt', 'pdf');
if(in_array($file_ext, $allowed)) {
if($file_error == 0) {
if($file_size <= 524288000) {
$file_name_new = uniqid('', true) . '.' . $file_ext;
$file_destination = '/var/www/html/uploads/' . $file_name_new;
if(move_uploaded_file($file_tmp, $file_destination)) {
echo $file_destination;
}
}
}
}
}
?>
I don't know why :( Thanks tho all!