使用此代码,我发布了表单ID fullfsbmut
,点击了ID fullforms
,并在div php
中收到alerterrorrr
的结果。
我收到所有表格,但我收不到输入文件
<script>
$('#fullforms').click(function() {
$.post('fullstep1.php',$("#fullfsbmut").serialize(), function(data) {
$('#alerterrorrr').html(data);
});
});
</script>
fullstep1.php的php文件
<?php session_start(); include_once("dbcon.php");
?>
<?php
function resize_image($file, $directory, $max_width = 200, $max_height = 170)
{
$full_file = $directory.$file;//ãæÞÚ ÇáÕæÑÉ ÇáßÇãá ãÚ ÇáÇãÊÏÇÏ
//ãÚÑÝÉ äæÚ ÇáÕæÑÉ Ëã ÇäÔÇÁ ÕæÑÉ Úáì ÎáÝíÊåÇ
if (eregi("\.png$", $full_file))
{
$img = imagecreatefrompng($full_file);
}
if (eregi("\.(jpg|jpeg)$", $full_file))
{
$img = imagecreatefromjpeg($full_file);
}
if (eregi("\.gif$", $full_file))
{
$img = imagecreatefromgif($full_file);
}
if (eregi("\.bmp$", $full_file))
{
$img = imagecreatefromwbmp($full_file);
}
$FullImage_width = imagesx($img);//ÚÑÖ ÇáÕæÑÉ ÇáÇÕáíÉ
$FullImage_height = imagesy($img);//ÇÑÊÝÇÚ ÇáÕæÑÉ ÇáÇÕáíÉ
//ÊÍÏíÏ ÚÑÖ æÇÑÊÝÇÚ ÇáÕæÑÉ ÇáÌÏíÏÉ
if (isset($max_width) && isset($max_height) && $max_width != 0 && $max_height != 0)
{
$new_width = $max_width;
$new_height = $max_height;
}
elseif (isset($max_width) && $max_width != 0)//ÇÐÇ áã íÍÏÏ ÇáÇÑÊÝÇÚ äÞæã ÈÊÍÏíÏå ÈÇáÊäÇÓÈ ãÚ ÇáÚÑÖ
{
$new_width = $max_width;
$new_height = ((int)($new_width * $FullImage_height) / $FullImage_width);
}
elseif (isset($max_height) && $max_height != 0)//ÇÐÇ áã íÍÏÏ ÇáÚÑÖ äÞæã ÈÊÍÏíå ÈÇáÊäÇÓÈ ãÚ ÇáÇÑÊÝÇÚ
{
$new_height = $max_height;
$new_width = ((int)($new_height * $FullImage_width) / $FullImage_height);
}
else
{
$new_height = $FullImage_height;
$new_width = $FullImage_width;
}
$full_id = imagecreatetruecolor($new_width, $new_height);//ÇäÔÇÁ ÇáÕæÑÉ ÇáÌÏíÏÉ
imagecopyresampled($full_id, $img, 0, 0, 0, 0, $new_width, $new_height, $FullImage_width, $FullImage_height);//äÓÎ ÇáÕæÑÉ ÇáÞÏíãÉ Úáì ÇáÌÏíÏÉ æÈÇáÇÈÚÇÏ ÇáÌÏíÏÉ
//ãæÞÚ æÇãÊÏÇÏ ÇáÕæÑÉ ÇáÌÏíÏÉ
if (eregi("\.(jpg|jpeg)$", $full_file))
{
$full = imagejpeg($full_id, $full_file, 60);
}
if (eregi("\.png$", $full_file))
{
$full = imagepng($full_id, $full_file);
}
if (eregi("\.gif$", $full_file))
{
$full = imagegif($full_id, $full_file);
}
if (eregi("\.bmp$", $full_file))
{
$full = imagewbmp($full_id, $full_file);
}
imagedestroy($full_id);//ÍÐÝ ÇáÕæÑÉ ÇáÞÏíãÉ
unset($max_width);//ÍÐÝ ÇáãÊÛíÑÇÊ
unset($max_height);
}
//ÇáÇÈÚÇÏ ÍÓÈ ÇáÍÇÌÉ ÊÓÊØíÚ ÊÛííÑ ÈÚÏ æÇÍÏ æÇáÈÚÏ ÇáÇÎÑ íÊÛíÑ ÈÇäÊÙÇã ãÚ ÇáÈÚÏ ÇáãÍÏÏ
?>
<?php
function rand_string($num_chars)
{
$chars = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
$string = array_rand($chars, $num_chars);
foreach($string as $s)
{
$ret .= $chars[$s];
}
return $ret;
}
$date = time();
$dat2e = md5(rand_string(8));?>
<?
if (isset($_COOKIE['id'])){
$title=$_POST['title'];
$photo=$_FILES['photo']['name'];
$message=$_POST['message'];
$price=$_POST['price'];
$contery=$_POST['contery'];
$mobile=$_POST['mobile'];
$showmobile=$_POST['showmobile'];
if(!$title){die('عنوان الاعلان غير مكتمل');}
if($_FILES['photo']['name']){die('برجاء اختيار صورة للاعلان');}
if(!$message){die('وصف الاعلان غير مكتمل');}
if(!$price){die('برجاء وضع السعر المحدد لاعلانك بالجنية المصري');}
if(!$contery){die('اختر الدولة');}
if(!$mobile){die('ملحوظة لم تضع رقم موبيلك سوف تفقد التواصل بالاعلان'.'<br/>');}
if(!$showmobile){echo'سوف لن يتم اظهار رقمك داخل هذة الاعلان';}
?><br/><a style="
width: 100%;
position: relative;
color: green;">جاري اضافة اعلانك خلال 5 ثواني</a>
<?
$message= strip_tags($message, '<br>');
$ddir='textads/'.date("Ymd").'/'. md5(time() + mt_rand()) . '.txt';
file_put_contents('./'.$ddir, $message);
$ssssdfgsadfgdfs=strlen($message);
if($ssssdfgsadfgdfs>'10000'){
unlink('../'.$ddir);
die('وصف الموضوع يحتوي علي اكتر من 10 الاف حرف');
}
$newphotopath = $date.$dat2e.$_FILES["photo"]["name"] ;
$uploadDir = './photos/'.date("Ymd").'/';
$nomFichier = $_FILES["photo"]["name"] ;
$nomTemporaire = $_FILES["photo"]["tmp_name"] ;
$uploadOk = move_uploaded_file($_FILES["photo"]["tmp_name"], $uploadDir.$newphotopath);
resize_image($newphotopath,$uploadDir, 280, 218);
$urlofimg='/photos/'.date("Ymd").'/'.$date.$dat2e.$_FILES["photo"]["name"];
$iiiiid=$_COOKIE['id'];
$DB = new DB;
$SQL_Insert_tripdata ="INSERT INTO ads(userid,title,photo,message,price,contery,mobile,showmobile) VALUES
('$iiiiid','$title','$urlofimg','$ddir','$price','$contery','$mobile','$showmobile') ";
$result = $DB->query($SQL_Insert_tripdata);
$used_id = mysql_insert_id();
}
?>
<meta http-equiv="refresh" content="5; url=add2-2.php?id=<? echo $used_id; ?>">