Jump to content

Bl4ckMaj1k

Members
  • Posts

    93
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Bl4ckMaj1k's Achievements

Member

Member (2/5)

0

Reputation

  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?
×
×
  • 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.