Jump to content


  • Posts

  • Joined

  • Last visited


Everything posted by Bl4ckMaj1k

  1. Yea no dice there. I don't have access to the file that is actually handling the upload process. My CMS is doing something in Python I believe. I have figured out a way to get my client to upload only one file at a time, however, I can't seem to figure out how to pass the appropriate variables to my CMS' script. For example, they require 'data' and 'caption'. $.ajax(function(){ url: '', type: '', data: {}, }); I don't know what to add to this portion of my new code to include the caption element.
  2. Hi Sam thanks for the reply. I sort of understand this thing a tad bit better, but still confused on some stuff. To start, I will say whenever I add 'files[]' (note the added brackets), I get an error. Its only when I submit one item at a time that I actually get the results I am looking for. So, is there a way to loop through each file and submit one at a time? This time, I can use the same element 'name="data"' without JS thinking I want to create an array. I don't know why, but arrays seem to error out. Only submitting one file at a time works in this case. However, I believe there is a way to take multiple files and sit them in sort of a que...this way, they come through the list and technically get uploaded one at a time. Not like an array, but just a step by step process. From there I gather all response data and save it all. Can this be done?
  3. OK how about a simplified version of this question... How would I make a file uploader with the same 'name' value (i.e. form name="data") loop through and send multiple files, one at a time?
  4. So I have a very unique issue for a project I am working on and I cannot seem to figure it out. I will try my best to explain the task at hand. I need to create an image uploader that will allow users to upload multiple images. Upon upload of their images, they will be required to submit a caption. Upon caption submission, the form will be sent to a script in our CMS (we use a provided CMS where code is extremely strange and out of our control). I have gotten this to work successfully using a single file upload, but whenever I attempt to run multiple files, I get a system error in our CMS. I think a little back story can help you all to understand the situation a bit more. Before I got this project thrown at me, our company used some Yahoo multi file uploader with all the bells and whistles and things that make people smile. Well the problem is, the smiles started to go away when every one of our customers began complaining about files not uploading correctly. So my boss came to me (the so called nerd of the office) and asked if I knew anything about file uploads. Of course, I replied. But I had no idea what they were looking to do. He then explained the issue and asked if I thought I could duplicate what they currently had. Anyone in Corporate America knows that I should've said no, but they also understand the importance of me saying, yes. In any event, it could possibly be my a** if this thing isn't functioning by COB Monday! I have all weekend to figure this thing out. Any help would be greatly appreciated. My Form I have a simple html form. It simply grabs the file and sends it to the server using a script provided to us by our CMS. We will never see what this script looks like but we do know that it works (seeing as the Yahoo file uploader worked...yes there were errors sometimes but overall it worked). So in the end, my HTML looked as follows: <form id="myForm" action="some_crazy_url/to_our_cms/file_uploader" method="post" enctype="multipart/form-data" target="hiddenframe"> <input type="file" multiple="multiple" id="file_1" name="data" /> Caption: <textarea name="caption"></textarea> <input type="submit" value="Submit Comment" /> </form> <iframe style=”width:300px;height:300px;border:0px;” name="hiddenframe" id="hiddenframe_obj" /> The name of the input field HAS to be 'data', that's how it returns info to the CMS. The required fields are 'data', and 'caption', both of which I have. When you submit this form, the following information is returned: NOTE: IGNORE THIS URL was actually a full blown URL but I removed it for obvious policy reasons. To me, this looks like some type of JSON feed which is good. It found the two variables successfully and is ready to be saved. I understand how to get to this step when there is only one file I am dealing with. But how can I do this for multiple files? I have tried the following with my HTML and neither worked: <form id="myForm" action="some_crazy_url/to_our_cms/file_uploader" method="post" enctype="multipart/form-data" target="hiddenframe"> <input type="file" multiple="multiple" id="file_1" name="data" /> <input type="file" multiple="multiple" id="file_2" name="data" /> Caption: <textarea name="caption"></textarea> <input type="submit" value="Submit Comment" /> </form> <iframe style=”width:300px;height:300px;border:0px;” name="hiddenframe" id="hiddenframe_obj" /> also tried... <form id="myForm" action="some_crazy_url/to_our_cms/file_uploader" method="post" enctype="multipart/form-data" target="hiddenframe"> <input type="file" multiple="multiple" id="file_1" name="data[]" /> Caption: <textarea name="caption"></textarea> <input type="submit" value="Submit Comment" /> </form> <iframe style=”width:300px;height:300px;border:0px;” name="hiddenframe" id="hiddenframe_obj" /> Both of these return errors. I have posted them below responsibly: 1.) 2.) I understand that my files are being processed correctly when processing one by one. This has to mean that it is possible to run some sort of script that allows for multiple versions of these files to be processed. I have some javascript/jquery/ajax know how, but not enough to understand what needs to be done here. I will be on this computer all day attempting to figure this thing out (there goes the weekend). I will reply to your responses, suggestions, tests immediately as well as expose as much information as I can without breaching policy. As I said before, any help would be greatly appreciated. Also, if you have any questions regarding anything I have went over in my question (regarding the CMS, form submission, deadline, my system, anything), feel free to ask. Fingers crossed! And as always, thanks in advance!! BlkMaj
  5. Totally get this now!!! Javascript is SUCH a powerful language. Sometimes with all the capabilities floating around I get a tad-bit confuzzled!! lol thanks for clearing things up! Solved. Bl4ck Maj1k
  6. Thanks nogray, I think I get what you mean. Can that be done in regular javascript? Because it almost looks like some form of jquery. Also, if you don't mind, can you elaborate on the example you provided. I am fairly new to Javascript. Thanks again! EDIT: What I am asking is how I would take my example, add it to your example to retreive what will basically become a hyperlink dependent on its mate in the array...does that make any sense? I hope I am wording this right!! lol
  7. Hello all!!! I'm back with a question... So I would like to create two separate arrays and have them relate to one another in Javascript. For example: var nameArray = new Array(); var urlArray = new Array(); nameArray = ['Jim', 'John', 'Chris', 'Smith']; urlArray = ['google.com', 'yahoo.com', 'msn.com', 'gmail.com']; I would like to pair these into a single array so I can click on Jim's name and get linked to google.com. I have tried several different approaches but so far nothing is working. I think I am just not understanding the overall concept of a multi-dimensional array. I don't understand how newArray[0][0] = "'Jim', 'Google.com'" would be data that I can use to create dynamic links depending on the place you are in the node. Please guys I could use a teacher right now....ready to be schooled LOL. As always, thanks in advance.
  8. Just increment by 2 until it reaches thirty...was this a test? did i pass? lol
  9. Got it and got it!!!! Thanks again fellas. Whenever I am confused I can ALWAYS depend on this place to keep me on track! You guys are incredibly smart. I can't wait for my PHP fluency to become as good as you all's. Another one bites the dust....SOLVED!
  10. Thanks WebStyles!!! I totally understand that now...awesome. So now, what does it mean when you do a post function with a bracketed variable next to it?? $_POST['someValue'][$someVariable] Thats the only thing left that I don't quite understand.
  11. I just would like to clarify so I don't look like a leecher or whatever people are calling lazy people these days LOL. Its not that I haven't tested this code. In fact I have played around with several different variations of it just to see its extent. Although I have seen it in action (thanks by the way, works like a charm), I would like to understand what's actually happening here. For example: $quantity = (!empty($_POST['quantity'][$key])) ? intval($_POST['quantity'][$key]) : 0; I know this is a true/false statement. But I didnt know you can put this inside of a variable. Also, what is the value of $quantity when you do this sort of statement? And I have never seen $_POST['someValue'][$someVariable] before. I don't understand what thats doing at all. And the other confusion: $arr_to_string = 'Item, quantity ' . implode(' , ',$arr); Is here. The variable arr_to_string is an array obviously with all of the $arr values stored in them. What I don't understand is the 2 single quotes inside the implode statement with the comma separating them. What does that mean? Why is that necessary? So many questions!! I wish I knew one of you PHP gurus personally LOL. Thanks again for the code and assistance guys. It's all really good stuff. Please help me understand it as you guys do. Bl4ck Maj1k
  12. I dont mean to be a bother, but do u mind explaining ur code in the english language?? lol I kinda get wat u did but....yea not really. I get it to a certain extent.
  13. Mikosiko, I think my problem is the syntax. I understand what I need to do in the English language lol....I just can't seem to convert it to PHP. The last thing you say, the "matter of process[ing] those arrays to construct my insert", thats where my issue lies. I cannot seem to grasp my mind around how I will manage to make each item associated with the corresponding amount. I feel so Noob lol.
  14. Good afternoon all!!! Need some help with a function I thought I understood....guess not. So I have a Javascript function that makes the following form every time the user hits the 'add item' button. The question is, how do I get the item name and amount stored?? I would like to make it so I capture the item he typed in and the amount of that item. That information needs to be stored in one row of the database. So example: So the database should have the following: The problem is I don't understand how to set up my foreach loop so each item knows which amount to reference. This is where I am so far foreach ($_POST['items'] as $item) { } Well thats not where I am lol but thats the only part I think I have correct. The rest was just foolishness that I have been playing around with....none of it has worked though. The real issue is the fact that these fields are dynamic. If I could give my Amount array individual keys, I could just set up my foreach like: foreach ($_POST['items'] as $item => $amount) { } And this would tell me which 'amount' is referencing which item because the item name would be the key. But how can I get the item name that the user just typed in?? This is driving me crazy!!! I keep trying different stuff but nothing seems to work. Here is the Javascript and HTML just in case you need it to fool around with: New Form Fields Javascript <script type="text/javascript"> function add_field(){ var max = 24; // total number of fields, adjust value as needed or for an unlimited number, just remove the test from the logic var cont = document.getElementById('add_here'); // refer to the div var numfields = cont.getElementsByTagName("input").length; // get number of input fields in the div var divNum = 0; if(numfields < max){ // create a div element var div1 = document.createElement('div'); // Get template data div1.innerHTML = document.getElementById('fieldtpl').innerHTML; // append to div, so that template data becomes part of document document.getElementById('add_here').appendChild(div1); divNum = divNum++; } else { alert("You have reached the maximum number of fields\n that can be added at one time!"); } } </script> New Form Fields HTML <div id="fieldtpl" style="display:none"> <div class="resource_form_label"> <input type="text" name="resource_form_label[]" value="" /> </div> <div class="resource_form_quantity"> Quantity </div> <div class="resource_form_quantity_textfield"> <input type="text" name="quantity[]" value="" size="3" /> </div> </div> Any help with this issue will be greatly appreciated!! Thanks in advance! Bl4ck Maj1k
  15. :-( I am still having issues with this. What's this key you speak of? I've seen it before (=>) but I don't understand it....I don't even know if that's the right symbol for it. Can you explain a bit further?
  16. Method 2 looks good and simple enough for me to utilize. So do I just run 2 separate foreach functions? One for the first batch (quantity[someName]) and another for the dynamic fields (dname[] and dquantity[]). If this is the case, how do I get the database to know when dname[] is associate with that specific dquantity[]. Sorry if I am frustrating you but this process is all so new to me!!! lol I just want to make sure I understand how this stuff is working for future references.
  17. One last question.... <form method="post" action="formaction.php" > <div id="addhere"> <div class="names"> <input type="text" name="name[]" value="some existing name" /> </div> <div class="quantity"> Quantity </div> <div class="quantity_field"> <input type="text" name="quantity[]" value="some existing qty"/> </div> </div> <a href="javascript:void(0);" onClick="add_field();">Click to add another name</a><br /> <input type="submit"> </form> <!-- Template. This whole section will be added directly to working div above --> <div id="fieldtpl" style="display:none"> <div class="names"> <input type="text" name="name[]" value="" /> </div> <div class="quantity"> Quantity </div> <div class="quantity_field"> <input type="text" name="quantity[]" value="" /> </div> </div> If you notice, the first Div has a textfield option. I want that to be static value. Not a type-able input field. For example: Chris Amy Tom Those are static values. They are already on our attendance sheets. I have, lets say for examples sake, 10 names currently on my list. Then I utilize those 'Other' fields. The issue is associating the values with one another. How do I create an array for 2 field values? Chris Quantity [] [] Would it be $_POST['name']['quantity'] ?? Sorry if thats a dumb question.
  18. EDIT: Solved....I had a div container issue. I had to look back at your code and I noticed the following <container Div> content <close Div> <button goes here> <new div to create (syntax) goes here> My order was way off before. I didn't understand that the button wasn't supposed to be inside the main div...until i noticed you were running an append method in the JavaScript which I assume it appends that html code to the div you defined as the parent.....brilliant! I can't wait for the day I understand Javascript as much as I do PHP, HTML, and CSS!!! Is it more complicated of a language? Overall, you are awesome!!! I really appreciate you and all the others on this forum who help all us 'Oober-Newbz' out when there is something we don't understand. Thanks a Million!!!!! Bl4ck Maj1k
  19. I'm sorry, I really don't mean to be a 'NewB' or a 'Leech' or whatever the kids are calling them these days....but I really have no idea how to just draw up an onclick event that writes all the data. Sort of the reason I posted here....hoping maybe I can get a helping hand in that department. I'm pretty savvy in PHP but when it comes to JS I really have no clue. I am currently reading one of the O'Reilly series books on coding with Javascript but unfortunately I had to read the PHP books first. So I am just on Chapter 2 (eek!!!). Any help would be greatly appreciated and thanks again! Bl4ck Maj1k
  20. Good afternoon my favorite people!!! Got a simple one for you all (well at least I was told it was easy by a friend who doesn't know JS)!! So I have a form that has a name and quantity of times that person appears on attendance sheets. For example What I need to do is make it possible for the user to be able to click a button and a new field comes up. The new field needs to have the same structure as the above data. Meaning a name, the quantity label, and an input field to enter some quantity value. However, for these fields, the name field will be left blank for the user to enter their own names...names that aren't on our current list of names. So each row in the above form would be 3 divs floating to the left (just to keep everything uniform, ive used classes). If I am the user, I would see a form that asks me to type in new name, then to the right of the word quantity, I would get the option to enter a value into a textbox. My question is: Is there a way to click a single button and javascript creates exactly what I have formatted? Meaning the following gets created with a single click of an add button: <div class="names"> <input type="text" name="I don't know what would need to be here" value="I dont know what would need to be here" /> <input type="hidden" name="name_labels[]" value="I don't know what would need to be here" /> </div> <div class="quantity"> Quantity </div> <div class="quantity_field"> <input type="text" name="quantity[Whatever went in the value of the hidden input] /> </div> Can someone help me out with this? Thanks in advance!!! Regards, Bl4ck Maj1k
  21. I'm a visual poet. I am sure I don't need to explain this but that's when your poems are intertwined with imagery...its a method of expressing what you say and depicting what you see as you say it. A lot of artists (painters and poets) lack the ability to put what they do into either imagery (poets) or words (painters). The real message is truly found when you turn those images into words or vice versa.
  22. That's awesome!!! I do a bit of artistry myself and I must say, you are quite correct when you say WE DESPISE LOGGING IN!!!! LOL The artwork being sorted by date, all displayed on one page is not bad. Its going to come down to the way you display everything. I hate tables so I suggest you use divs and float them all left. This way, if you size it correctly, the line breaks will happen automatically. For example, if your container div is 100 and each image container is only 20, then you will have 5 images in each row. Make sure the image div and image display is inside the while loop so you only have to type it once. $display_images = ''; while ($row = mysql_fetch_array($someSql)) { $image_name = $row['image_name']; $display_images .= '<div class="images"> <img src="images/' . $image_name . ' /> </div> } Then, in the page body, you would echo this out to display your divs. Make sure the class 'images' is sized properly and floating to the left. <div id="image_container"> <?php echo "$display_images" ?> </div> Lastly, make sure the ID image_container is whatever will generate a perfect number for your images. For example if you want 10 images to display per row, then make sure this is big enough for exactly 10 images. Assuming 20px width of each image, to have 10 images you need a div of EXACTLY 200px (10images * 20px each). You will also want to make sure you date stamp all your uploaded artwork using either the function 'now()' or the date() function. Also when setting up your database be sure to use Date datatypes because you will need to perform date math when sorting by most recent date. The about us page should be pure HTML so thats a breeze. I will say, if users don't have to be logged in to upload things, then hackers could find your site and attempt an attack. Ensure nothing but image files can be uploaded which can be done using something like this... $allowed = array("image/jpeg", "image/gif", "application/pdf"); if(!in_array($file_type, $allowed)) { //some error } Bl4ck Maj1k
  23. Javascript is the only language that can handle what you are trying to do. PHP can only run conditions when an action is made. Checking a checkbox or clicking a radio button does not constitute as an actual 'action'. Javascript will do whatever you want. Crazy thing is, just this morning I went to W3Schools and learned a large amount of Javascript. What you wish to achieve can be done so simply with Javascript!!! Basically you need to do something like the following (and please, any Javascript experts correct me if I am wrong) : if (document.getElementById('checkbox_id').checked) { //Do some stuff... }else if(document.getElementById('other_checkbox_id').checked) { //do_something_else } Remember, your id can be a variable, an array, whatever you need it to be to get the results. Now when it comes to what exactly goes between the 'if' or the 'elseif' statement still confuses me....Good Luck!!!!
  24. For us Noobs, can someone please break down what's going on in this form?? (in Lamens terms?)
  • 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.