سلام یه فرم درست کردم برای آپلود فایل همه چیزش کار میکنه به جز اینکه اگه فایل ارسال میکنم مقدار null میاره
انگار که اصلا فایلی براش ست نکردم
کمک کنید
<div class="col-lg-12">
<h1 class="col-lg-3">عضویت در اتاق بازرگانی</h1>
<form method="post" action="#">
<div class="col-lg-9">
<div class="col-lg-12">
<div class="col-lg-12">مبالغ پرداختی به ریال می باشد</div>
<div class="col-lg-3"><input type="radio" value="1" name="type_reg">عادی 2500000</div>
<div class="col-lg-3"><input type="radio" value="2" name="type_reg">رسمی 2500000</div>
<div class="col-lg-3"><input type="radio" value="3" name="type_reg">ویژه 5000000</div>
</div>
<div class="col-lg-12">
<input type="text" class="form-control" name="name" id="name" required placeholder="نام شما">
</div>
<div class="col-lg-12">
<input type="text" class="form-control" name="family" id="family" required placeholder="نام خانوادگی شما">
</div>
<div class="col-lg-12">
<input type="text" class="form-control" name="tell" id="tell" required placeholder="شماره تماس شما">
</div>
<div class="col-lg-12">
<input type="email" class="form-control" name="email" id="email" required placeholder="ایمیل شما">
</div>
<div class="col-lg-12">
<input type="text" class="form-control" name="username" id="username" required placeholder="نام کاربری شما">
</div>
<div class="col-lg-12">
<input type="password" class="form-control" name="password" id="password" required placeholder="پسورد شما">
</div>
<div class="col-lg-12">
<input type="password" class="form-control" name="password2" id="password2" required placeholder="تکرار پسورد">
</div>
<div class="col-lg-12">
<div class="col-lg-6"><label>پیوست مدارک :</label></div>
<div class="col-lg-6"><input type="file" class="form-control" name="file" id="file" required>
</div>
</div>
<div class="col-lg-12">
<label>سوال ثبت نام : پایتخت ایران ؟</label>
</div>
<div class="col-lg-12">
<input type="text" class="form-control" name="soal" id="soal" required placeholder="جواب سوال">
</div>
<div class="col-lg-3">
<input type="submit" class="btn btn-success" name="send_reg" value="عضویت">
</div>
</div>
{res}
</form>
</div>
<?PHP
require_once ROOT_DIR.'/language/'.$config['langs'].'/website.lng';
if(!defined('DATALIFEENGINE'))
{
die("Hacking attempt!");
}
/*function Check_Post($value){
$Ckeck_Sql_Injection=str_replace(array('<','=','>',';',',',"'",'"','#','+','/','*','-','!','&',')',']','}','$','^'),'',$value);
return $Ckeck_Sql_Injection;
}*/
$res = '';
if(isset($_POST['send_reg'])){
if(!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['family']) || !isset($_POST['tell'])
|| !isset($_POST['username'])|| !isset($_POST['password']) || !isset($_POST['password2']) || !isset($_POST['soal']))
{
$res='<p style="color:red">تمامی فیلدها باید تکمیل گردد</p>';
}
else
{
$soal=stripslashes(strip_tags($_POST['soal']));
$name =stripslashes(strip_tags($_POST['name']));
$email = stripslashes(strip_tags($_POST['email']));
$family =stripslashes(strip_tags($_POST['family']));
$full_name=$name.' '.$family;
$tell =stripslashes(strip_tags($_POST['tell']));
$date=strtotime('now');
$user=stripslashes(strip_tags($_POST['username']));
$pass=stripslashes(strip_tags($_POST['password']));
$pass2=stripslashes(strip_tags($_POST['password2']));
if((strcmp($pass,$pass2)==0) and (strcmp($soal,'تهران')==0))
{
$pass=md5(md5($pass));
$reg_type=$_POST['type_reg'];
switch ($reg_type) {
case '1':
$reg_type='عادی';
$price='2500000';
break;
case '2':
$reg_type='رسمی';
$price='2500000';
break;
case '3':
$reg_type='ویژه';
$price='5000000';
break;
default:
$res='<p style="color:red">مبلغی انتخاب نشده است</p>';
die();
}
$db->query( "SELECT name from " .PREFIX."_users where LOWER(name) = '" . strtolower( $name ) . "' OR LOWER(email) = '" . strtolower( $email ) . "'" );
if( $db->num_rows() > 0 ) {
$res='<p style="color:red">ایمیل یا نام درخواستی شما قبلا در سیستم ثبت شده است</p>';
}
else{
if(isset($_FILES["file"]["type"]))
{
$validextensions = array("zip");
$temporary = explode(".", $_FILES["file"]["name"]);
$file_extension = end($temporary);
if ((($_FILES["file"]["type"] == "application/zip") || ($_FILES["file"]["type"] == "application/x-zip-compressed")
|| ($_FILES["file"]["type"] == "multipart/x-zip") || ($_FILES["file"]["type"] == "application/x-compressed")) && ($_FILES["file"]["size"] < 1000000)//Approx. 100kb files can be uploaded.
&& in_array($file_extension, $validextensions)) {
if ($_FILES["file"]["error"] > 0)
{
$res='<p style="color:red">مشکل در آپلود مدارک</p>';
}
else
{
$filename=$_FILES['file']['name'];
$file=md5($filename.microtime()).substr($filename,-5,5);
if (file_exists(ROOT_DIR . "/uploads/files/".$file)) {
$res='<p style="color:red">فایلی با این نام از قبل آپلود شده است</p>';
}
else
{
$db->query("INSERT INTO `".PREFIX."_users` (`email`, `password`,
`name`,`news_num`, `comm_num`, `user_group`, `lastdate`,
`reg_date`, `banned`, `allow_mail`, `info`, `signature`, `foto`,
`fullname`, `land`, `icq`, `yahoo`, `favorites`, `pm_all`, `pm_unread`,
`time_limit`, `xfields`, `allowed_ip`, `hash`, `logged_ip`, `restricted`,
`restricted_days`, `restricted_date`, `timezone`,`tell`,`reg_type`,`price`,`file`)
VALUES
('{$email}', '{$pass}', '{$user}', '0', '0', '4', '0',
'{$date}', '', '1', '', '', '', '{$full_name}', '',
'', '', '', '0', '0', '', '', '',
'', '', '0', '0', '', '','{$tell}','{$reg_type}','{$price}','{$file}')");
$id = $db->insert_id();
if($id)
{
$sourcePath = $_FILES['file']['tmp_name']; // Storing source path of the file in a variable
$targetPath = ROOT_DIR . "/uploads/files/".$file; // Target path where file is to be stored
move_uploaded_file($sourcePath,$targetPath) ; // Moving Uploaded file
$res='<p style="color:red">آپلود با موفقیت انجام شد</p>';
//$res='<p style="color:green">ثبت نام موفق لطفا هزینه را در مرحله بعد پرداخت کنید</p> ';
/*$to = '[email protected]';
$subject = 'عضویت جدید در خبرنامه';
$message = "
نام : ".$name."
ایمیل :".$email."
تاریخ ثبت :".$date."
";
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);*/
}
else{
$res='<p style="color:red">مشکل در ثبت نام</p>';
}
}
}
}
else
{
$res='<p style="color:red">مشکل در نوع فایل و حجم فایل</p>';
}
}
}
}
else
{
$res='<p style="color:red">پسورد های ورودی یکسان نمی باشند یا جواب سوال درست وارد نشده است</p>';
}
}
}
$tpl->set( '{res}', $res);
$tpl->load_template( 'register2.tpl' );
$tpl->compile( 'content' );
$tpl->clear();
?>
لطفا کمک کنید
مشکل چیه که فایل نمیگیره؟



