yasin5
دوشنبه 03 تیر 1392, 18:07 عصر
با سلام من سایت طراحی کردم که کاربر میتونه فایلی را اپلود کنه میخوام فقط تا 20 مگا بتونه ودر ضمن مشخص بشه کدام کاربر فرستاده این کدی که قرار میدهم فقط فایل اپلود میشه ولی چه کاربری فرستاده مشخص نیست
<?php
session_start();
require('config/config.php');
mysql_query("set names 'UTF8'");
$query="select * from ketab2 where name='".$_POST['name']."'";
$result=mysql_query($query);
if ((mysql_num_rows($result))>0)
{
header('location:upload.php?msg=1');
} @$file = $_FILE['FileName'];
$isEx = new SplFileInfo($file);
$ext = array('pdf' => 'pdf');
$rEx = $isEx->getExtension();
@$fSize = $_FILE['FileName']['size'];
if( isset( $ext[$rEx] ) == $rEx && $fSize < 20768 )
{
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/".$_FILES["file"]["name"]);
echo 'کتاب شما پس از بررسی توسط مدیر سایت، به نمایش خواهد آمد';
}
else {
header('location:upload.php?msg2=1');
}
if (( strlen($_POST['name'])==0) || (strlen($_POST['subject'])==0) ||(strlen($_POST['author'])==0)||(strlen($_POST['publisher'])==0))
{
header('location:upload.php?msg0=1');
}
if(($_POST['name'] == '')|| ($_POST['subject'] == '')||($_POST['author'] == '')||($_POST['publisher'] == '')||($_POST['detail'] == ''))
{
header('location:upload.php?msg1=1');
}
else {
$query="insert into ketab2 (name,subject ,author, publisher,detail)values('".$_POST['name']."','".$_POST['subject']."','".$_POST['author']."','".$_POST['publisher']."','".$_POST['detail']."')";
mysql_query($query) or die(mysql_error());
mysql_close($connect);
$_SESSION['name']=$_POST['name'];
$_SESSION['subject']=$_POST['subject'];
$_SESSION['author']=$_POST['author'];
$_SESSION[' publisher']=$_POST[' publisher'];
$_SESSION['detail']=$_POST['detail'];
header('location:complete1.php');
}
?>
<?php
session_start();
require('config/config.php');
mysql_query("set names 'UTF8'");
$query="select * from ketab2 where name='".$_POST['name']."'";
$result=mysql_query($query);
if ((mysql_num_rows($result))>0)
{
header('location:upload.php?msg=1');
} @$file = $_FILE['FileName'];
$isEx = new SplFileInfo($file);
$ext = array('pdf' => 'pdf');
$rEx = $isEx->getExtension();
@$fSize = $_FILE['FileName']['size'];
if( isset( $ext[$rEx] ) == $rEx && $fSize < 20768 )
{
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/".$_FILES["file"]["name"]);
echo 'کتاب شما پس از بررسی توسط مدیر سایت، به نمایش خواهد آمد';
}
else {
header('location:upload.php?msg2=1');
}
if (( strlen($_POST['name'])==0) || (strlen($_POST['subject'])==0) ||(strlen($_POST['author'])==0)||(strlen($_POST['publisher'])==0))
{
header('location:upload.php?msg0=1');
}
if(($_POST['name'] == '')|| ($_POST['subject'] == '')||($_POST['author'] == '')||($_POST['publisher'] == '')||($_POST['detail'] == ''))
{
header('location:upload.php?msg1=1');
}
else {
$query="insert into ketab2 (name,subject ,author, publisher,detail)values('".$_POST['name']."','".$_POST['subject']."','".$_POST['author']."','".$_POST['publisher']."','".$_POST['detail']."')";
mysql_query($query) or die(mysql_error());
mysql_close($connect);
$_SESSION['name']=$_POST['name'];
$_SESSION['subject']=$_POST['subject'];
$_SESSION['author']=$_POST['author'];
$_SESSION[' publisher']=$_POST[' publisher'];
$_SESSION['detail']=$_POST['detail'];
header('location:complete1.php');
}
?>