Jump to content
Larry Ullman's Book Forums

HartleySan

Members
  • Posts

    3047
  • Joined

  • Last visited

  • Days Won

    243

Posts posted by HartleySan

  1. Here's the copy and paste from my other message:

    **********************************

     

    BASE_URI refers to the base directory of your server, which should be outside the public HTML directory, and inaccessible from www.domain-name.com.

     

    I can't tell you what string to use for the BASE_URI constant, as this is completely dependent on the hosting environment provided by your hosting company. Please contact them if you cannot figure this out on your own.

    If you have some sort of control panel for your site though, it should be listed in there somewhere.

     

    The BASE_URL constant is just the www.domain-name.com string. Obviously, domain-name needs to change to whatever the correct domain is.

     

    The other two are based on the BASE_URI constant, but the idea is that there should be a directory called "pdfs" within the root directory of your server, and the MySQL script should also be in the base directory, so that both are inaccessible from the web.

     

    That all make sense?

    Also, in the future, please post your questions on the forum so that everyone can benefit from them.

    Thanks.

  2. That's valid, and I apologize for any steam-inducing comments I made.

     

    I spend my days these days working for a bunch of university types that don't understand technology at all, and I quite often get the most ridiculous requests that are akin to, "Could you please build a Google search engine by yourself in a week?" or, "This sucks right now, but if you make this one little thing animate, then it'll be perfect."

    Because it's my job (and also because I enjoy the challenge), I quite often try to accept their requests as best I can, but I also know all too well the feeling of someone else making a request like it's nothing, when you know full and well how much work it is to make that "simple request" a reality.

     

    With that said though, I have also come to realize that most of the time, the requests are reasonable and fair, and as such, I really should try my best to grant them, as they lead to a better overall experience.

    And if nothing else, I try to put a positive spin on everything and realize that the reality is no matter who you work with, you will always get too many unreasonable requests, tons of gold plating, etc., but it will make you a better programmer.

     

    Anyway, I simply wanted to share that anecdote because I wanted to convey the fact that I know how you must have felt when I made those comments.

     

    Luckily, when you're only allowing images for uploads, it's not that hard to keep things secure. In my experience, the end all-be all is to simply make a new copy of the image and discard the old one. That will stop any tomfoolery.

    And it's usually a necessary step anyway, as most sites quite often have to make several sizes for a given image to handle responsive layouts.

     

    Anyway, I didn't mean to cause you a lot of headaches. I know it's hard when you're still learning JS and jQuery, but I just wanted to share my thoughts.

    Best of luck with the site.

    • Upvote 1
  3. It doesn't work because getElementsByClassName returns an array (technically, a node list, which is an array-like structure).

     

    My advice would be to use querySelector and querySelectorAll instead of getElementsByClassName, as the former have better browser support and are easier to use in all cases.

     

    If there is only one element in the DOM with a given class name, then you can use querySelector and reference the returned element like getElementById. However, if you need to capture multiple elements, then you will need to use querySelectorAll/getElementsByClassName, and loop through the results set.

     

    As a side note, innerHTML does not change the href of the link, it changes the text within the opening and closing tags.

    That help?

  4. Copying the uploaded images into a div is as simple as creating a bunch of Image objects with the proper src properties and appending them as children of the div in the DOM.

    That shouldn't be hard at all.

     

    And as for the SWFUpload plug-in, I would drop that immediately.

    The link you sent me to says that it has not been under development for years, and as you know, iDevices do not even support Flash.

     

    I would either go with a simple PHP upload solution, or if you don't want to reload the page, use XHR2's File API in combo with a hidden Ajax iframe hack for older browsers.

  5. Roger Federer's backhand can be troublesome, yes. Hehe!

     

    I would recommend a different approach to this problem.

    Write the CSS classes necessary to completely style the div and GIF the way you want them, including an opacity of 0. (Here's a quick link for opacity in old IE: http://css-tricks.com/snippets/css/cross-browser-opacity/).

     

    Next, write a function that allows you to easily create instances of this image placeholder as many times as you need. For example:

    function createImgPlaceholder() {
      
      var div = document.createElement('div'),
        img = new Image();
      
      div.className = 'class-for-GIF-containing-div';
      img.className = 'thumbnail';
      img.src = '/images/ajax/ajax-loader-item.gif';
      div.appendChild(img);
      
      return div;
      
    }
     
    Then, when you need say 10 of these placeholders, run a loop that calls the createImgPlaceholder function 10 times, and place all of those on the screen.
    Upon rendering the ten instances on the screen, you could then even attach an additional class to each, which would create a nice transition from opacity 0 to opacity 1.
     
    Finally, to handle the inconsistent loading of the GIF to begin with, the easy solution is to preload the GIF so that it's in the browser cache.
    Here is my favorite technique for preloading images:
     
    Any questions?
    • Upvote 1
  6. That is one way to do it, yes.

    As a side note, you're better off making the anonymous function into a named function elsewhere, and then just referencing that function by name as the argument for the each method.

    By doing that, you're only creating one function object in memory, as opposed to the countless ones you are now. For example, if the each method executes 20 times, then you are creating 20 different function objects, which is a waste of memory.

     

    Just my two cents.

    • Upvote 1
  7. The CSS file will simply "pretty up" stuff, and likely not affect the functionality.

    With that said, pull open your browser console and look for any errors that might be getting output.

    Likely, your either aren't putting the file(s) in the right place, or you are not correctly referencing the objects/functions in the library.

     

    Without more info, it's hard to help though.

    Thanks.

    • Upvote 1
×
×
  • Create New...