Jump to content

searls03

Members
  • Posts

    907
  • Joined

  • Last visited

Everything posted by searls03

  1. ok, so I have a code where it takes documents and uploads them as soon as selected. I want to know how I can put in my genRandomString() in so that not only will the doc upload, but this random string will submit to database, but I need this string to be the same for all documents that are uploaded on a single page load.....when page refreshes, new string, else it stays the same. I am going to link this number as an id in the database so that it can be identified. does this make any sense at all?????? <?php function genRandomString($length = 20) { $characters = '0123456789'; $string =''; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters))]; } return $string; } ?> <!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 : "9999999999999999999999999999999999", file_types : "*", file_types_description : "Image files", file_upload_limit : 1000, 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(){ //Remove from queue on cancel click 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/'+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> </head> <body> <div id="swfupload-control"> <p>Upload upto 5 image files(jpg, png, gif), each having maximum size of 1MB(Use Ctrl/Shift to select multiple files)</p> <input type="button" id="button" /> <p id="queuestatus" ></p> <ol id="log"></ol> </div> </body> </html>
  2. how can I make a hidden form field inside this code with a value of genRandomString()? .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>';
  3. is there a way to make $id the same for all entries based from this code? <?php include_once "secure/connect_to_mysql.php"; function genRandomString($length = 20) { $characters = '0123456789'; $string =''; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters))]; } return $string; } $uploaddir = 'images/'; $id= genRandomString(); $file = $uploaddir . basename($_FILES['uploadfile']['name']); $size=$_FILES['uploadfile']['size']; if($size>999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999) { 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)"; } $sql = "INSERT INTO pictures(image, id) VALUES('$file', '$id')"; $rs = mysql_query($sql) or die ("Problem with the query: $sql<br>" . mysql_error()); echo mysql_error(); ?>
  4. or is that like a server side thing?
  5. can you tell me where this is defined? +file.name+
  6. do you know of anyway that I could type in the name and then have it submit with each file?
  7. but I want to be able to type the name in..........and then it submits with no submit button.......is this the same way I would do it........
  8. one more thing(I think)....how can I add a field called eventname so that for each file that is submitted to the database with the code drummin gave me, so that each picture uploaded in the page load will all have the same event name.........does this make sense. so basically I want the eventname to post at the same time the file piece posted........the problem I am running into is not using a submit button.....
  9. sorry, so i need to change var pathtofile='<a href="images/'+file.name+'" target="_blank" >view »</a>'; into a php variable that can be submitted......all though this will need to be an array. or maybe a better way is to say that I want to take each file name and submit it to the database, only thing is that the files upload directly to the server after the upload is complete. I am going to take the file path and put it in a slideshow, but I need to make it so that the file path, the code I posted above, will be in the database. does this make more sense?????
  10. does this make any sense at all???????? :confused: :confused:
  11. this right here is what I want to change to a string to submit.....how can I do this? var pathtofile='<a href="images/'+file.name+'" target="_blank" >view »</a>';
  12. and here is upload-file.php <?php include_once "secure/connect_to_mysql.php"; $uploaddir = 'images/'; $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 { echo "error ".$_FILES['uploadfile']['error']." --- ".$_FILES['uploadfile']['tmp_name']." %%% ".$file."($size)"; } ?>
  13. sorry there is so much code, but how can I make it so that the flash upload piece of this will be able to send variables, such as file name, to upload-file.php.....so that things can go into my database. does this make sense? if you need a working example, tell me and I will send you a PM with the address (don't want too many people knowing where this happens at...... <!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 : "9000000000000000000000000000", file_types : "*", file_types_description : "Image files", file_upload_limit : 1000, 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/'+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> </head> <body> <h3>» Multiple File Upload With Progress Bar</h3> <div id="swfupload-control"> <p> </p> <input type="button" id="button" /> <p id="queuestatus" ></p> <ol id="log"></ol> </div> </body> </html>
  14. ok, here is the main part: if ($_POST['submit']) { $name = $_POST['name']; $id = $_POST['id']; $image = $_POST['image']; $event = $_POST['event']; $template = 'template.php'; $picture = '$name.png'; $id = genRandomString(); //this could be the uploaded picture $target_path = "images/"; foreach ($_FILES["uploadedfile"]["name"] as $key => $value) { $uploadfile = $target_path . basename($_FILES[uploadedfile][name][$key]); //echo $uploadfile; if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'][$key], $uploadfile)) { echo $value . ' uploaded<br>'; } //we need just the filename - no extension $picture_name = pathinfo($picture, PATHINFO_FILENAME); I dont want to change it really, because I do not want the couple of files that it can upload to stop unless I know what the problem is......
  15. var counter = 1; var limit = 10; function addInput(divName){ if (counter == limit) { alert("You have reached the limit of adding " + counter + " inputs"); } else { var newdiv = document.createElement('div'); newdiv.innerHTML = "<br><input type='file' name='uploadedfile[]'>"; document.getElementById(divName).appendChild(newdiv); counter++; } }
  16. well it didn't upload, I just checked.
  17. same thing happened, no errors came up though :( :( :confused:
  18. no, it just clears the fields and goes back to before it started uploading, but nothing uploaded. :confused:
  19. can anyone tell me why this code doesn't work if it tries to upload like more than 3 files?: <?php include_once "secure/connect_to_mysql.php"; function genRandomString($length = 20) { $characters = '0123456789'; $string =''; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters))]; } return $string; } if ($_POST['submit']) { $name = $_POST['name']; $id = $_POST['id']; $image = $_POST['image']; $event = $_POST['event']; $template = 'template.php'; $picture = '$name.png'; $id = genRandomString(); //this could be the uploaded picture $target_path = "images/"; foreach ($_FILES["uploadedfile"]["name"] as $key => $value) { $uploadfile = $target_path . basename($_FILES[uploadedfile][name][$key]); //echo $uploadfile; if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'][$key], $uploadfile)) { echo $value . ' uploaded<br>'; } //we need just the filename - no extension $picture_name = pathinfo($picture, PATHINFO_FILENAME); $sql = "INSERT INTO pictures (name, id, image, event) VALUES('$name', '$id','images/$value','$event')"; $rs = mysql_query($sql) or die ("Problem with the query: $sql<br>" . mysql_error()); echo mysql_error(); } copy($template, "$event.php"); } ?> <form action="new.php" method="post" enctype="multipart/form-data"><input name="id" type="hidden" value=<?php echo $id; ?> /><br /> Event Name:<input name="event" type="text" /><input name="image" id="image" type="hidden" value="images/<?php echo $value; ?>" /><input type="hidden" name="MAX_FILE_SIZE" value="900000000000000000000000000000000000000000000000000000000000000000000000000" /> Choose a file to upload: <div id="dynamicInput"> <br>Picture:<input type="file" id="file" name="uploadedfile[]" onClick="addInput('dynamicInput');" > </div> <input type="button" value="Add another text input" onClick="addInput('dynamicInput');"> <br /><input name="submit" type="submit" value="submit" /></form> is it the code or something else?
  20. the problem is that I want display the order from both tables, so like it would be content from table1, table2, table1. it displays as table1, table1, table2. it puts them in the correct order, but not from both tables, so all table1's first in the right order, then all table2s in the right order, I want them to "intermix" so to speak.....
  21. more specifically, with this code? <?php session_start(); // Must start session first thing /* Created By Adam Khoury @ www.flashbuilding.com -----------------------June 20, 2008----------------------- */ // Here we run a login check if (!isset($_SESSION['id'])) { echo 'Please <a href="/login.php">log in</a> to access your account'; exit(); } //Connect to the database through our include include_once "connect_to_mysql.php"; // Place Session variable 'id' into local variable $userid = $_SESSION['id']; // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM members WHERE userid='$userid' LIMIT 1"); while($row = mysql_fetch_array($sql)){ $name = $row["name"]; $phone = $row["phone"]; $username = $row["username"]; $address = $row["address"]; $city = $row["city"]; $state = $row["state"]; $zip = $row["zip"]; $cell = $row["cell"]; $email = $row["email"]; $accounttype = $row["accounttype"]; $rank = $row["rank"]; $badges = $row["badges"]; $userid = $row["userid"]; } ?> <?php include 'config.php'; include 'opendb.php'; // if no id is specified, list the available articles if(!isset($_GET['id'])) { $query = "SELECT * FROM messages WHERE recipient ='$name' order by date desc"; $result = mysql_query($query) or die('Error : ' . mysql_error()); // create the article list while($row = mysql_fetch_array($result, MYSQL_NUM)) { list($from1, $recipient, $title1, $content, $id, $date, $read) = $row; if ($read == "1"){ $content1 .= "<table border='0' cellpadding='0' cellspacing='0' width='1200'> <tr><td valign='top' width='274'> $from1</td> <td valign='top' border='1' width='1025'><a href='message.php?id=$id'>$title1</a></td></tr></table><br /> "; }else{ $content1 .= "<table border='0' cellpadding='0' cellspacing='0' width='1200'> <tr bgcolor='#CCCC99'><td width='274'><strong>$from1</strong></td><td width='1025'> <a href='read.php?id=$id'>$title1</a></td></tr></table><br /> "; }} }else { // get the article info from database $query = "SELECT * FROM messages WHERE recipient='$name' ORDER by date desc"; $result = mysql_query($query) or die('Error : ' . mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $title = $row['title']; $content = $row['content']; $to = $row['recipient']; $from = $row['from1']; $id = $row['id']; $read = $row['read']; } // if no id is specified, list the available articles if(!isset($_GET['id'])) { $self = $_SERVER['PHP_SELF']; $query = "SELECT * FROM comments WHERE recipient='$name' order by date desc"; $result = mysql_query($query) or die('Error : ' . mysql_error()); // create the article list while($row = mysql_fetch_array($result, MYSQL_NUM)) { list($com_id, $userid, $id1, $id, $recipient, $comment, $sender, $title, $date, $read) = $row; if ($read == "1"){ $content1 .= "<table border='0' cellpadding='0' cellspacing='0' width='1200'> <tr><td valign='top' width='274'>$sender</td> <td valign='top' width='1025'> <a href='reply.php?com_id=$com_id'>$title</a></td></tr></table><br /> "; }else { $content1 .= "<table border='0' cellpadding='0' cellspacing='0' width='1200'> <tr bgcolor='#CCCC99'><td valign='top' width='274'><strong>$sender</strong></td> <td valign='top' width='1025'><a href='read1.php?com_id=$com_id'>$title</a> </form></td></tr></table><br /> "; } } } else { // get the article info from database $query = "SELECT * FROM comments WHERE recipient='$name' order by date desc"; $result = mysql_query($query) or die('Error : ' . mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $userid = $row['userid']; $id1 = $row['id1']; $id = $row['messageid']; $recipient = $row['recipient']; $comment = $row['comment']; $sender = $row['sender']; $title = $row['title']; $read = $row['read']; } include 'closedb.php'; ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.