الرفع عن طريق jquery
مثال على ذلك
http://vip4ksa.net/upload.html
ملفات الدرس في المرفقات
تم الاستعادة باضافه للجي كويري
وهي ملف jquery.ocupload-1.1.2
ملف الرفع
كود PHP:
<html xmlns="http://www.w3.org/1999/xhtml" dir="rtl" xml:lang="ar" lang="ar">
<head>
<script src="jquery-1.3.min.js" type="text/javascript"></script>
<script src="jquery.ocupload-1.1.2.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
$('#upload1').upload({
name: 'links',
method: 'post',
enctype: 'multipart/form-data',
action: 'upload2.php',
onSubmit: function() {
$('#progress1').html('<div class=categories><img alt="" src="loadingAnimation.gif"/></div>');
},
onComplete: function(data) {
$('#progress1').html(data);
}
});
});
</script>
<div>اختر ملف <input id="upload1" type="File"> </div>
<div id="progress2"></div>
<div id="progress1"></div>
</body>
</html>
ملف ما بعد الرفع :funny:
كود PHP:
<?php
@header('(anti-spam-content-type:) text/html; charset=windows-1256');
@header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
@header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
@header ("Cache-Control: no-cache, must-revalidate");
@header ("Pragma: no-cache");
$ex=array("image/gif","image/pjpeg","image/jpeg");//مصفوفه وضعنا فيها انواع الملفات المقبوله
$type=$_FILES['links']['type']; //استقبلنا نوع الملف من خلال المصفوفه files
if(!in_array($_FILES['links']['type'],$ex))//التأكد من عدم وجود نوع الملف ضمن المصفوفه
{
exit("<br /> صيغه الملف غير معتمده $type");
}
else
{
if($type=="image/gif")
{
$xit=".gif";
}
elseif($type=="image/pjpeg" or "image/jpeg")
{
$xit=".jpg";
}
$link="up_";
$link.=rand(0,999999999);
$link.=$xit;
$path2="up/";
$path2.=$link;
$paths2="up/";
$paths2.=$link;
$up=move_uploaded_file($_FILES['links']['tmp_name'],$path2);
echo'<img alt="" src="'.$path2.'" />';
}
?>
سوف تجد اننا استخدمنا امرين
امر onSubmit
بعد اختيار الملف
و امر onComplete
بعد الانتهاء من الرفع
انتهاء