• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

newsletter module

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I want to create a newsletter module from where i can send newsletters to multiple emails. The images will be embedded in the email.

Now, let me describe the problem:
The body for the email(html code) is pasted into the text area.
Now, to embed the image, i need to upload the image to the server.
How do i upload the image, probably after extracting the src from the image tag?
Is it possible since the field is not of file type?
If my approach is not correct what is a possible approach?
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could parse the HTML that is uploaded either manually or using an XML validator (although good luck handling poorly formatted HTML). Its a good idea especially if you want to make sure people don't upload malicious code, as an example, such parsers usually remove all but the most basic HTML tags like bold/italic/etc. One its parsed, finding the img tag is then trivial.

Another method is just to convert the entire html file into a single string and try using regular expressions to match an image tag.

Really for uploading files though, I recommend a form upload button to explicitly upload the files. There's no telling how many files or how big they will be if you start uploading from external sites.
[ August 16, 2006: Message edited by: Scott Selikoff ]
 
Scott Selikoff
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BTW if you are going to upload the files and save them locally, you're going to need to re-parse the HTML anyway to replace the original URL with a local URL.
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you might find this helpful

http://kupu.oscom.org/screenshots/
 
azhar bharat
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies.
Actually I can extract the file details from the html. That is not the problem now.
My problems are
after i extract the file details, what do i do next? ie how do i upload the files given in the html?
If it is not possible, please suggest a workaround.
As i said the field is just textarea and not file field.
I have never done this before so any help is welcome.
[ August 16, 2006: Message edited by: azhar bharat ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even if you know the location of an image file on the client machine, you're not going to be able to get the browser to upload it to you without the user explicitly clicking on a 'file' input button, selecting the image and submitting your form.
Browser makers take great care to insure that this is the only way an upload is performed.
 
reply
    Bookmark Topic Watch Topic
  • New Topic