السلام عليكم
كيف حالكم إن شاء الله تمام ومبارك عليكم الشهر الكريم
انا عندي سكربت تحميل بالجافا سكربت والاجاكس ... تحميل الملفات من غير تحديث للصفحه
هوا يشتغل تمام ومافيه اي مشكله بس انه لا يقبل ملفات بحروف عربيه
فا عملت له كود بـ php لعمل نصوص وارقام عشوائيه ،، و النصوص والارقام هاذي راح تكون هي الاسم الجديد للملف المرفوع
و اضفت لها الاجاكس عشان يعمل بدون تحديث للصفحه وكله تمام الحمدالله
لكن المشكله اني لمن احمل اكثر من ملف الكود يعمل على اول ملف فقط
وهاذا المثال هنا لتوضيح المشكله , المثال يقبل صور من نوع gif فقط>> http://www.m1fk.com/demo
وهاذي اكواد السكربت تبعي وشرحها
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Multiple File Upload With Progress Bar - Web Developer Plus Demos</title>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/swfupload/swfupload.js"></script>
<script type="text/javascript" src="js/jquery.swfupload.js"></script>
<script type="text/javascript">
$(function(){
$('#swfupload-control').swfupload({
upload_url: "upload-file.php",
file_post_name: 'uploadfile',
file_size_limit : "1024",
file_types : "*.gif",
file_types_description : "Image files",
file_upload_limit : 5,
flash_url : "js/swfupload/swfupload.swf",
button_image_url : 'js/swfupload/wdp_buttons_upload_114x29.png',
button_width : 114,
button_height : 29,
button_placeholder : $('#button')[0],
debug: false
})
.bind('fileQueued', function(event, file){
var listitem='<li id="'+file.id+'" >'+
'File: <em>'+file.name+'</em> ('+Math.round(file.size/1024)+' KB) <span class="progressvalue" ></span>'+
'<div class="progressbar" ><div class="progress" ></div></div>'+
'<p class="status" >Pending</p>'+
'<span class="cancel" > </span>'+
'</li>';
$('#log').append(listitem);
$('li#'+file.id+' .cancel').bind('click', function(){
var swfu = $.swfupload.getInstance('#swfupload-control');
swfu.cancelUpload(file.id);
$('li#'+file.id).slideUp('fast');
});
// start the upload since it's queued
$(this).swfupload('startUpload');
})
.bind('fileQueueError', function(event, file, errorCode, message){
alert('Size of the file '+file.name+' is greater than limit');
})
.bind('fileDialogComplete', function(event, numFilesSelected, numFilesQueued){
$('#queuestatus').text('Files Selected: '+numFilesSelected+' / Queued Files: '+numFilesQueued);
})
.bind('uploadStart', function(event, file){
$('#log li#'+file.id).find('p.status').text('Uploading...');
$('#log li#'+file.id).find('span.progressvalue').text('0%');
$('#log li#'+file.id).find('span.cancel');
})
.bind('uploadProgress', function(event, file, bytesLoaded){
//Show Progress
var percentage=Math.round((bytesLoaded/file.size)*100);
$('#log li#'+file.id).find('div.progress').css('width', percentage+'%');
$('#log li#'+file.id).find('span.progressvalue').text(percentage+'%');
})
.bind('uploadSuccess', function(event, file, serverData){
var item=$('#log li#'+file.id);
item.find('div.progress').css('width', '100%');
item.find('span.progressvalue').text('100%');
هنا المخرجات بعد التحميل عملت مربع نص وسيكون فيه ناتج عمليه خلق ارقام و حروف عشوائيه
var pathtofile= 'here name :<input type="text" id="T1" size="20">'+file.type ;
item.addClass('success').find('p.status').html('Done!!! | '+pathtofile);
generate('5');
function generate(lengthn) {
هاذا الفوكشن اضفته ليقوم بالاتصال بملف البي اتش بي ليخلق حروف وارقام عشوائيه
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
هنا اعطاء الناتج بعد اخذه من ملف البي اتش بي لخلق ارقام و حروف عشوائيه الى مربع النص T1
document.getElementById("T1").value=xmlhttp.responseText;
}
}
xmlhttp.open("GET","upload-file.php?q="+lengthn,true);
xmlhttp.send();
}
})
.bind('uploadComplete', function(event, file){
// upload has completed, try the next one in the queue
$(this).swfupload('startUpload');
})
});
>>>> كوود لـ css
</script>
<style type="text/css" >
#swfupload-control p{ margin:10px 5px; font-size:0.9em; }
#log{ margin:0; padding:0; width:500px;}
#log li{ list-style-position:inside; margin:2px; border:1px solid #ccc; padding:10px; font-size:12px;
font-family:Arial, Helvetica, sans-serif; color:#333; background:#fff; position:relative;}
#log li .progressbar{ border:1px solid #333; height:10px; background:#fff; }
#log li .progress{ background:#999; width:0%; height:10px; }
#log li p{ margin:0; line-height:18px; }
#log li.success{ border:1px solid #339933; background:#ccf9b9; }
#log li span.cancel{ position:absolute; top:5px; right:5px; width:20px; height:20px;
background:url('js/swfupload/cancel.png') no-repeat; cursor:pointer; }
</style>
</head>
<body>
<h3>» Multiple File Upload With Progress Bar</h3>
<div id="swfupload-control">
<p>Upload upto 5 image files(jpg, png, gif), each having maximum size of 1MB</p>
<input type="button" id="button" />
<p id="queuestatus" ></p>
<ol id="log"></ol>
</div>
</body>
</html>
وهاذا كود البي اتش بي لرفع الملفات وخلق ارقام عشوائيه
$uploaddir = './uploads/';
$file = $uploaddir . basename($_FILES['uploadfile']['name']);
$size=$_FILES['uploadfile']['size'];
if($size>1048576)
{
echo "error file size > 1 MB";
unlink($_FILES['uploadfile']['tmp_name']);
exit;
}
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
echo "success";
} else {
}
//هنا يأخذ القيمه المرسله من ملف الجافا سكربت و يحولها الى ارقام عشوائيه
$q = $_GET["q"];
$passlen = $q;
$charset = "abcdefghijklmnopqrstuvwxyz1234567890";
for($i=0; $i<$passlen; $i++) {
$random = rand() % strlen($charset);
$temp = substr($charset, $random, 1);
$password.=$temp;
}
echo $password;
?>
<?php
الله يعطيكم العافيه لا تبخلو على فا السكربت عامله مجاني لوجه الله ..
واذا ما فهمت مني ايش الي ابغاه بالزبط ياريت تسآلني عشان اوضحلك
جزاكم الله خير