PDA

View Full Version : سوال: قطع اجرای برنامه



numberone1
چهارشنبه 29 شهریور 1391, 08:47 صبح
سلام من یک کد دارم که اینه

<?php
ob_start();
$upload_url = 'upload-file.php';
$file_size_limit = '1024';
$file_type = '*.*';
$file_type_description = 'all files';
$file_upload_limit = '5';
?>
<!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>آپلود فایل</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: "<?php echo $upload_url; ?>",
file_post_name: 'uploadfile',
file_size_limit : "<?php echo $file_size_limit; ?>",
file_types : "<?php echo $file_type; ?>",
file_types_description : "<?php echo $file_type_description; ?>",
file_upload_limit : "<?php echo $file_upload_limit; ?>",
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+'" >'+
'فایل: <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" >در حال ارسال</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('slow');
});
$.ajax({
type: 'HEAD',
url: 'uploads/'+file.name,
timeout: 5000,
cancel: $('#log li#'+file.id).find('span.cancel').text('انصرا ف'),
success: function() {
answer = confirm('فایلی با این نام قبلا آپلود شده است آیا میخواهید جایگزین کنید؟ '
+ $('#log li#'+file.id).find('span.cancel').text('انصرا ف'));
if(answer){
$('#log li#'+file.id).find('span.cancel').text('انصرا ف');
$('li#'+file.id+' .cancel').bind('click', function(){
var swfu = $.swfupload.getInstance('#swfupload-control');
swfu.cancelUpload(file.id);
$('li#'+file.id).slideUp('fast');
});
}else{$('#log li#'+file.id).find('span.cancel').text('انصرا ف');
$('li#'+file.id+' .cancel').bind('click', function(){
var swfu = $.swfupload.getInstance('#swfupload-control');
swfu.cancelUpload(file.id);
$('li#'+file.id).slideUp('fast');
});
}
},
error: function() {
$('#log li#'+file.id).find('span.cancel').text('انصرا ف');
$('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('فایل های انتخاب شده: '+numFilesSelected+' / فایل های در انتظار: '+numFilesQueued);
})
.bind('uploadStart', function(event, file){
$('#log li#'+file.id).find('p.status').text('در حال بار گزاری');
$('#log li#'+file.id).find('span.progressvalue').text('0%' );
$('#log li#'+file.id).find('span.cancel').text('انصرا ف');
})
.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(perc entage+'%');
})
.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='<a href="uploads/'+file.name+'" target="_blank" >نمایش &raquo;</a>';
item.addClass('success').find('p.status').html('ا نجام شد | '+pathtofile);
$('#log li#'+file.id).find('span.cancel').hide();
})
.bind('uploadComplete', function(event, file){
// upload has completed, try the next one in the queue
$(this).swfupload('startUpload');
})

});

</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:5px; background:#fff; }
#log li .progress{ background:#999; width:0%; height:5px; }
#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>

<div id="swfupload-control">
<input type="button" id="button" />
<p id="queuestatus" ></p>
<ol id="log"></ol>
</div>

</body>
</html>


یه شرطی هست توی برنامه که این هست و من سئوالم دقیقا به این مربوط میشه


$.ajax({
type: 'HEAD',
url: 'uploads/'+file.name,
timeout: 5000,
cancel: $('#log li#'+file.id).find('span.cancel').text('انصرا ف'),
success: function() {
answer = confirm('فایلی با این نام قبلا آپلود شده است آیا میخواهید جایگزین کنید؟ '
+ $('#log li#'+file.id).find('span.cancel').text('انصرا ف'));
if(answer){
$('#log li#'+file.id).find('span.cancel').text('انصرا ف');
$('li#'+file.id+' .cancel').bind('click', function(){
var swfu = $.swfupload.getInstance('#swfupload-control');
swfu.cancelUpload(file.id);
$('li#'+file.id).slideUp('fast');
});
}else{$('#log li#'+file.id).find('span.cancel').text('انصرا ف');
$('li#'+file.id+' .cancel').bind('click', function(){
var swfu = $.swfupload.getInstance('#swfupload-control');
swfu.cancelUpload(file.id);
$('li#'+file.id).slideUp('fast');
});
}
},
error: function() {
//do nothing
});
}
});

میخوام اگر کسی این تائیدیه که باز میشه جلوش و کلید کنسل و زد توش اجرای برنامه متوقف شه
هر کاری میکنم نمیشه
از break; استفاده کردم نشد . از exit() php استفاده کردم نشد .این کد ها رو هم که گذاشتم بازم کار نمی کنه!!

numberone1
چهارشنبه 29 شهریور 1391, 08:52 صبح
توی یکی از فایل های جاوا اسکریپت که توی برنامه لود شده این متد ها هست با اینا میشه کاری کرد؟

SWFUpload.prototype.stopUpload = function () {
this.callFlash("StopUpload");
};

و این

SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
if (triggerErrorEvent !== false) {
triggerErrorEvent = true;
}
this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
};

numberone1
چهارشنبه 29 شهریور 1391, 08:54 صبح
اینم هستش


var SWFUpload;
if (typeof(SWFUpload) === "function") {
SWFUpload.queue = {};

SWFUpload.prototype.initSettings = (function (oldInitSettings) {
return function () {
if (typeof(oldInitSettings) === "function") {
oldInitSettings.call(this);
}

this.queueSettings = {};

this.queueSettings.queue_cancelled_flag = false;
this.queueSettings.queue_upload_count = 0;

this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler;
this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler;

this.settings.queue_complete_handler = this.settings.queue_complete_handler || null;
};
})(SWFUpload.prototype.initSettings);

SWFUpload.prototype.startUpload = function (fileID) {
this.queueSettings.queue_cancelled_flag = false;
this.callFlash("StartUpload", [fileID]);
};

SWFUpload.prototype.cancelQueue = function () {
this.queueSettings.queue_cancelled_flag = true;
this.stopUpload();

var stats = this.getStats();
while (stats.files_queued > 0) {
this.cancelUpload();
stats = this.getStats();
}
};

SWFUpload.queue.uploadStartHandler = function (file) {
var returnValue;
if (typeof(this.queueSettings.user_upload_start_handl er) === "function") {
returnValue = this.queueSettings.user_upload_start_handler.call( this, file);
}

// To prevent upload a real "FALSE" value must be returned, otherwise default to a real "TRUE" value.
returnValue = (returnValue === false) ? false : true;

this.queueSettings.queue_cancelled_flag = !returnValue;

return returnValue;
};

SWFUpload.queue.uploadCompleteHandler = function (file) {
var user_upload_complete_handler = this.queueSettings.user_upload_complete_handler;
var continueUpload;

if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) {
this.queueSettings.queue_upload_count++;
}

if (typeof(user_upload_complete_handler) === "function") {
continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
} else if (file.filestatus === SWFUpload.FILE_STATUS.QUEUED) {
// If the file was stopped and re-queued don't restart the upload
continueUpload = false;
} else {
continueUpload = true;
}

if (continueUpload) {
var stats = this.getStats();
if (stats.files_queued > 0 && this.queueSettings.queue_cancelled_flag === false) {
this.startUpload();
} else if (this.queueSettings.queue_cancelled_flag === false) {
console.debug('ydfsdfgsdfgsdfg');
this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]);
this.queueSettings.queue_upload_count = 0;
} else {
this.queueSettings.queue_cancelled_flag = false;
this.queueSettings.queue_upload_count = 0;
}
}
};
}

kb0y667
دوشنبه 17 مهر 1391, 05:22 صبح
اگه خودت حلش نکنی هیچکس دیگه ای حلش نمیکنه

(شوخی) میخوای چندصفحه کد پی اچ پی هم من بچسبونم رو صفحه ؟ :لبخندساده: