thenewperson Posted November 23, 2009 Share Posted November 23, 2009 Found this upload site and got it to work and all but the error message doesnt work. On their upload if file size is to big , a l javascript error pops up saying file size limit is greater, but when i put a few more lines of code the error code doesnt work anymore. It doesnt cuase error but just ignores it. The upload system works complelty and if file goes over the file limit than it fails to upload but it doesnt tell user. What i want is error code to work again but i didnt really change that much. Only added different path. The code that doesnt ccause error but works in demo but not when i use it .bind('fileQueueError', function(event, file, errorCode, message){ alert('Size of the file '+file.name+' is greater than limit'); site i got the upload from http://webdeveloperplus.com/jquery/multiple-file-upload-with-progress-bar-using-jquery/ upload.php <?php include("loginsystem/include/session.php"); include("loginsystem/include/constants.php"); ?> <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <meta name="description" content="php,file hosting" /> <link rel="stylesheet" href="likeftp.css" style="text/css" /> <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 : "0", file_types : "*.jpg;*.png;*.gif;* .zip;", 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').hide(); }) .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='<a href="uploads/users/files/fi/<?php //adding username to path $user = $session->username; $sql =mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error()); mysql_select_db(DB_NAME, $sql) or die(mysql_error()); $foldq = "SELECT * FROM users WHERE username='$user'"; $resultfold=mysql_query($foldq); $num2=mysql_fetch_row ($resultfold); echo $num2[6]; ?>/'+file.name+'" target="_blank" >view »</a>'; item.addClass('success').find('p.status').html('Done!!! | '+pathtofile); }) .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> <div id="swfupload-control"> <p>You may upload up to 10 files(gif,jpeg,png,zip)</p> <input type="button" id="button" /> <p id="queuestatus" ></p> <ol id="log"></ol> file-upload.php <?php include("loginsystem/include/session.php"); include("loginsystem/include/constants.php"); $user = $session->username; if(isset($user) && strlen(trim($user)) > 0 ){ //remove spaces from username $user = trim($user) ; } else { echo "you must be logged in"; } //check if username is alpha if(!ctype_alnum($user)){ echo "your name is not valid"; } //connect to database $sql =mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error()); mysql_select_db(DB_NAME, $sql) or die(mysql_error()); //geting username from db $foldq = "SELECT * FROM users WHERE username='$user'"; $resultfold=mysql_query($foldq); $num2=mysql_fetch_row ($resultfold); //path $the_path = 'uploads/users/files/fi/' ; $user_dir = $the_path . $num2[6] . "/"; if( ! is_dir ( $user_dir ) ){ //search for folder if( ! mkdir( $user_dir , 0755 ) ){ // create folder if not made } } $file = $user_dir . basename($_FILES['uploadfile']['name']); $size=$_FILES['uploadfile']['size']; if($size>1048576*0){ echo "error file size > 1 MB"; unlink($_FILES['uploadfile']['tmp_name']); exit; } if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) { echo "success"; } else { echo "error ".$_FILES['uploadfile']['error']." --- ".$_FILES['uploadfile']['tmp_name']." %%% ".$file."($size)"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/182700-need-phpbit-of-ajax-help/ Share on other sites More sharing options...
thenewperson Posted November 24, 2009 Author Share Posted November 24, 2009 no one? Quote Link to comment https://forums.phpfreaks.com/topic/182700-need-phpbit-of-ajax-help/#findComment-964421 Share on other sites More sharing options...
thenewperson Posted November 24, 2009 Author Share Posted November 24, 2009 still need help Quote Link to comment https://forums.phpfreaks.com/topic/182700-need-phpbit-of-ajax-help/#findComment-965011 Share on other sites More sharing options...
l0ve2hat3 Posted November 25, 2009 Share Posted November 25, 2009 http://www.uploadify.com/ is so much easier/better Quote Link to comment https://forums.phpfreaks.com/topic/182700-need-phpbit-of-ajax-help/#findComment-965205 Share on other sites More sharing options...
l0ve2hat3 Posted November 25, 2009 Share Posted November 25, 2009 file_size_limit : "0", that may have something to do with it... set it to something greater than zero Quote Link to comment https://forums.phpfreaks.com/topic/182700-need-phpbit-of-ajax-help/#findComment-965209 Share on other sites More sharing options...
thenewperson Posted November 25, 2009 Author Share Posted November 25, 2009 file_size_limit : "0", that may have something to do with it... set it to something greater than zero mm think there misunderstanding trying to get the error to show if it passes the file size aloud. So i set it to zero so i can use any file for testing. Quote Link to comment https://forums.phpfreaks.com/topic/182700-need-phpbit-of-ajax-help/#findComment-965684 Share on other sites More sharing options...
thenewperson Posted November 25, 2009 Author Share Posted November 25, 2009 nvm, tryed what you said and it worked ^^ thought any number would work as long as it passed Quote Link to comment https://forums.phpfreaks.com/topic/182700-need-phpbit-of-ajax-help/#findComment-965689 Share on other sites More sharing options...
oni-kun Posted November 25, 2009 Share Posted November 25, 2009 nevermind, tryed what you said and it worked ^^ thought any number would work as long as it passed "show if it passes the file size aloud". 0 in settings usually means infinite, so it will never call the JS function. Quote Link to comment https://forums.phpfreaks.com/topic/182700-need-phpbit-of-ajax-help/#findComment-965713 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.