Hi guys, i have this script that uploads thru ftp, the upload is working now i need to make some verifications but im new to php i belive its something like this, can someone take a look?
thanks
[code=php]<html>
<head>
</head>
<body>
<?php
ini_set(‘display_errors’, 1);
ini_set(‘log_errors’, 1);
ini_set(‘error_log’, dirname(__FILE__) . ‘/log/error_log.txt’);
error_reporting(E_ALL);
set_time_limit(0);
if( $_SERVER[‘REQUEST_METHOD’]==’POST’ )
{
echo ($_GET[‘stud’]);
echo ($_GET[‘exam’]);
echo ($_GET[‘center’]);
echo ($_GET[‘pat’]);
echo ($_GET[‘visit’]);
$data == date()
if ($_POST[“arquivo”]==””) echo “<script>alert(‘File is empty’);windows.close();</script>”
if substr($arquivo, -4) <> “.zip” echo “<script>alert(‘Only Zip files are allowed’);windows.close();</script>”
$filepath = ($_GET[‘stud’]”/”$_GET[‘pat’]);
if (file_exists($filepath) else {mkdir($filepath);}
$nomefile = ($stud+_+$exam+_+$center+_+$pat+_+$visit+_+$data+”.zip”)
rename($_POST[“arquivo”], $nomefile);
var_dump( $_FILES );//apenas para debug retirar no fim
$servidor = ‘22.22.20.2’;
$caminho_absoluto = $filepath;
$arquivo = $_FILES[‘arquivo’];
$con_id = ftp_connect($servidor) or die( ‘No conectou em: ‘.$servidor );
ftp_login( $con_id, ‘c12c’, ‘1234’ );
ftp_put( $con_id, $caminho_absoluto.$arquivo[‘name’], $arquivo[‘tmp_name’], FTP_BINARY );
}
?>
<form action=”” method=”post” enctype=”multipart/form-data”>
<input type=”file” name=”arquivo” />
<input type=”submit” name=”enviar” value=”Enviar” />
</form>
</body>
</html>