|
 |
|
สอบถามเรื่องการใช้งาน uploadify หน่อยครับ พอดีมีปัญหาเกี่ยวกับการใช้งาน พอจะมีใครช่วยได้บ้างหว่าา |
|
 |
|
|
 |
 |
|
ตัวอย่าง Code
Code (PHP)
<script>
var queueSize = 0;
function startUpload(id){
if(queueSize == 0){
//insert your form submit function call here
//alert("Nothing in the queue");
sent_data_img('design/get_data_intro.php');
}else{
jQuery('#'+id).uploadify('upload');
}
}
jQuery(document).ready(function() {
/* กรอกได้เฉพาะภาษาอังกฤษ*/
jQuery.validator.addMethod("Engkey", function(value, element) {
return this.optional(element) || /^[a-z0-9\-]+$/i.test(value);
}, "ต้องเป็นภาษาอังกฤษเท่านั้น");
//$j("#frm").validate();
jQuery('#frm').validate({
rules: {
title: {
required: true
}
},
messages: {
title: {
required: "หัวข้อ"
}
},
submitHandler: function() {
//startUpload('int_bg');
alert(jQuery('.inputFileUploadify').attr('id'));
}
});
jQuery(".inputFileUploadify").each(function() {
var myID = jQuery(this).attr('id');
jQuery('#' + myID).uploadify({
'swf' : '<?=_BASEURL_?>/swf/uploadify.swf',
'method' : 'post',
'uploader' : 'design/get_data_intro.php',
'displayData' : 'percentage',
'simUploadLimit': 1,
'queueSizeLimit': 1,
'fileSizeLimit' : '500KB',
'fileTypeDesc' : 'Image Files',
'fileTypeExts' : '*.gif; *.jpg; *.png',
'auto' : false,
'onUploadStart' : function(file) {
jQuery('#' + myID).uploadify("settings", "formData", {"id" : <?=$id?>, "timestamp" : '<?php echo $timestamp;?>', 'token' : '<?php echo md5('unique_salt' . $timestamp);?>', "title": jQuery("#title").val(), "method": '<?=$method?>' });
},
'onUploadSuccess' : function(file, data, response) {
jQuery('#status').dialog({ modal: true, height: "auto", width: "250px", open: function(event, ui) { jQuery('body').css('overflow','hidden');}, close: function(event, ui) { jQuery('body').css('overflow','auto'); } }).html(data);
},
'onSelect' : function(file) {
queueSize = file.name;
}
});
});
});
</script>
Code (PHP)
<table border="1" align="center" width="627" id="table1" class="grid2">
<tr>
<td width="150">หัวข้อ :</td>
<td><input name="title" type="text" id="title" value="" /></td>
</tr>
<tr>
<td>รูปภาพ : </td>
<td>
<input type="file" id="int_img" name="int_img" class="inputFileUploadify"/>
</td>
</tr>
<tr>
<td>รูปภาพปุ่ม : </td>
<td>
<input type="file" id="int_botton" name="int_botton" class="inputFileUploadify"/>
</td>
</tr>
<tr>
<td>รูปพื้นหลัง : </td>
<td>
<input type="file" id="int_bg" name="int_bg" class="inputFileUploadify"/>
</td>
</tr>
</table>
<input name="Submit" type="submit" class="register-button" id="submit" value="บันทึกข้อมูล">
ปัญหาที่เจอคือ alert(jQuery('.inputFileUploadify').attr('id')); ใน submitHandler ลอง alert ดูแล้ว ขึ้น เป็น Undentify
แต่พอย้ายตำแหน่งออกมานอก submitHandler กลับมีค่า show ตามปกติครับ ไม่ทราบว่าจะแก้ไขยังไงได้บ้างครับ ตอนนี้ตันไปหมดแล้ว
submitHandler << ตัวนี้คือ Jquery validate ครับ เอาไว้เช็คค่าเมื่อมีการ submit ส่วน uploadify ที่ผมใช้ ผมให้มีการเช็คค่า ถ้าไม่มีการเลือกไฟล์อัพโหลด จะให้ไปทำงานในส่วนของขั้นตอน sent_data_img('design/get_data_intro.php'); ส่วนหากมีค่าอัพโหลด ก็จะเรียก uploadify เพื่อใช้งานครับ
ผมอยากให้ค่าของ alert(jQuery('.inputFileUploadify').attr('id')); ไม่แสดงเป็น undentify จะแก้ยังไงดีครับ
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2013-03-14 14:25:02 |
By :
iaunz |
View :
1050 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองทดสอบดู
Code (PHP)
<script>
var queueSize = 0;
function startUpload(id){
if(queueSize == 0){
//insert your form submit function call here
//alert("Nothing in the queue");
sent_data_img('design/get_data_intro.php');
}else{
jQuery('#'+id).uploadify('upload');
}
}
jQuery(document).ready(function() {
// เพิ่ม เรียกใช้งานได้ตามปกติ
test();
function test()
{
jQuery(".inputFileUploadify").each(function() {
var myID = jQuery(this).attr('id');
alert(myID);
});
}
//
/* กรอกได้เฉพาะภาษาอังกฤษ*/
jQuery.validator.addMethod("Engkey", function(value, element) {
return this.optional(element) || /^[a-z0-9\-]+$/i.test(value);
}, "ต้องเป็นภาษาอังกฤษเท่านั้น");
//$j("#frm").validate();
jQuery('#frm').validate({
rules: {
title: {
required: true
}
},
messages: {
title: {
required: "หัวข้อ"
}
},
submitHandler: function() {
//startUpload('int_bg');
alert(jQuery('.inputFileUploadify').attr('id'));
}
});
jQuery(".inputFileUploadify").each(function() {
var myID = jQuery(this).attr('id');
jQuery('#' + myID).uploadify({
'swf' : '<?=_BASEURL_?>/swf/uploadify.swf',
'method' : 'post',
'uploader' : 'design/get_data_intro.php',
'displayData' : 'percentage',
'simUploadLimit': 1,
'queueSizeLimit': 1,
'fileSizeLimit' : '500KB',
'fileTypeDesc' : 'Image Files',
'fileTypeExts' : '*.gif; *.jpg; *.png',
'auto' : false,
'onUploadStart' : function(file) {
jQuery('#' + myID).uploadify("settings", "formData", {"id" : <?=$id?>, "timestamp" : '<?php echo $timestamp;?>', 'token' : '<?php echo md5('unique_salt' . $timestamp);?>', "title": jQuery("#title").val(), "method": '<?=$method?>' });
},
'onUploadSuccess' : function(file, data, response) {
jQuery('#status').dialog({ modal: true, height: "auto", width: "250px", open: function(event, ui) { jQuery('body').css('overflow','hidden');}, close: function(event, ui) { jQuery('body').css('overflow','auto'); } }).html(data);
},
'onSelect' : function(file) {
queueSize = file.name;
}
});
});
});
</script>
เพิ่ม Function test สามารถใช้งานได้ตามปกติ แต่พอ จับยัดไปในส่วนของ validate ในส่วนของ submitHandler กลับไม่มีค่าโชว์
|
 |
 |
 |
 |
Date :
2013-03-14 15:39:55 |
By :
iaunz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
guest
|
 |
 |
 |
 |
Date :
2013-03-14 15:41:50 |
By :
cookiephp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
guest แล้ว ? ยังไง งง
|
 |
 |
 |
 |
Date :
2013-03-14 16:02:43 |
By :
iaunz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|