I need to build some client side code which follows this use case:
- An image is uploaded via ftp with a name like “1.jpeg” or “1.png” (the “1” is based on the id set in the database)
- I need to inject an img onto the page with a src attribtue of “1.jpeg” or “1.png” (depending on which file actually exists)
My current idea is to create another spot into phpMyAdmin to dictate file type, however I’d like to avoid that (because it depends on non-programmers/designers correctly identifying filetypes). Any thoughts?
If the client gets no more information than the id, then you’ve only got three options as far as I see:
404s until you hit a200response and then use that (pretty nasty solution).<img src='/getimage?id=1' />(much nicer solution, but isn’t pure javascript which you imply is what you want).