<?php
// Verifico se si vuole fare ulpoad di un file
if ( isset($_POST['uploaded-file']) ) {
echo "Entrato";
$file_name = $_FILES["uploaded-file"]["name"];
if ( $file_name == "" ) {
header('Location: ../home/index.php?error=1');
//echo "Non hai indicato alcun file per l'upload!";
return;
}
if ( is_uploaded_file($_FILES["uploaded-file"]["tmp_name"]) && $_FILES["uploaded-file"]['error'] == UPLOAD_ERR_OK ) {
// Creo il percorso in cui verrà salvato il file
$path = $_SESSION['path'].$file_name;
if ( !file_exists( $path ) ) {
if ( move_uploaded_file($_FILES["uploaded-file"]["tmp_name"], $path) ) {
$file_type = 2;
$exploded = explode('.', $file_name);
$format = $exploded[count($exploded)-1];
$query = "select name from file_type where format = '".$format."' limit 1;";
$result = $conn->query( $query );
if ( $result->num_rows == 1 ) {
$row = $result->fetch_array( MYSQLI_ASSOC );
$file_type = $row['format'];
}
$password = null;
if ( isset($_POST['file-password']) ) {
$password = $_POST['file-password'];
}
$file = sha1_file( $path );
// Aggiorno la tabella che tiene traccia dei file dell'utente
$query = "insert into ".$_SESSION['user_id']."_files (file_name, file_path, file_type, owner, password, file) values ('".$file_name."', '".$_SESSION['path']."', '".$file_type."', '".$_SESSION['user_id']."', '".$password."', '".$file."');";
if ( !$conn->query( $query ) ) {
header('Location: ../home/index.php?error=5');
//echo 'Errore inserimento nel database.';
} else {
echo 'success';
header('Location: ../home/');
}
} echo {
header('Location: ../home/index.php?error=6');
//echo "Impossibile fare l'upload del file.";
}
} else {
header('Location: ../home/index.php?error=7');
//echo "Esiste già un file con lo stesso nome!";
}
} else {
header('Location: ../home/index.php?error=8');
//echo "Problemi nell'upload del file.";
}
}
?>
- Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.28, 5.4.0 - 5.4.29
- Parse error: syntax error, unexpected '{' in /in/CIWHf on line 66
Process exited with code 255. - Output for 5.0.0 - 5.0.5
- Parse error: parse error, unexpected '{' in /in/CIWHf on line 66
Process exited with code 255. - Output for 4.4.2 - 4.4.9
- Parse error: syntax error, unexpected '{', expecting ',' or ';' in /in/CIWHf on line 66
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
- Parse error: parse error, unexpected '{', expecting ',' or ';' in /in/CIWHf on line 66
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error, expecting `','' or `';'' in /in/CIWHf on line 66
Process exited with code 255.
preferences:
209.86 ms | 1386 KiB | 119 Q