thenewperson Posted November 7, 2009 Share Posted November 7, 2009 Trying to send a error message that file goes past the limit, but the page only runs when there no errors. But when there is errors it doesnt say there is and still goes on as if it succeeds. The file uploads to the right path i have set and everything works fine but cant get the error message to show. The upload page with button <? 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 : "512000", file_types : "*.jpg;*.png;*.gif;* .zip;", file_types_description : "Image files", file_upload_limit : 10, 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: true }) .bind('fileQueued', function(event, file){ var listitem='<li id="'+file.id+'" >'+ 'File: <em>'+file.name+'</em> ('+Math.round(file.size/1046)+' 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 $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> //this is the button that uploads <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> upload php <?php include("loginsystem/include/session.php"); include("loginsystem/include/constants.php"); $user = $session->username; if(isset($user) && strlen(trim($user)) > 0 ){ $user = trim($user) ; } else { echo "you must be logged in"; } if(!ctype_alnum($user)){ echo "your name is not valid"; } $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); $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']; //my attempt to error the upload by setting file sizie greater than 0 if($size>1048576*0){ echo "<script type=\"text/javascript\"> alert(\"error file size > 5 MB\"); </script>"; 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)"; } ?> i know the way i did sql connection is bit crapy atm but trying to get error message to wor firrst. this is the oringal upload script but uploa-file.phhp is modifyed http://webdeveloperplus.com/jquery/multiple-file-upload-with-progress-bar-using-jquery/ Link to comment https://forums.phpfreaks.com/topic/180694-need-phpjavascript-help/ Share on other sites More sharing options...
thenewperson Posted November 7, 2009 Author Share Posted November 7, 2009 meant to say the first file is named upload.php which contains the button to upload files the second file is upload-file.php which holds tests and moving the file to the path but having problems with error message wont show. in the upload-file php Link to comment https://forums.phpfreaks.com/topic/180694-need-phpjavascript-help/#findComment-953353 Share on other sites More sharing options...
thenewperson Posted November 8, 2009 Author Share Posted November 8, 2009 still cant figure this out >< Link to comment https://forums.phpfreaks.com/topic/180694-need-phpjavascript-help/#findComment-953445 Share on other sites More sharing options...
thenewperson Posted November 8, 2009 Author Share Posted November 8, 2009 errm Link to comment https://forums.phpfreaks.com/topic/180694-need-phpjavascript-help/#findComment-953463 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.