Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

newsletter module

 
azhar bharat
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • 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?
 
Scott Selikoff
author
Saloon Keeper
Posts: 4010
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • 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
Saloon Keeper
Posts: 4010
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • 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.
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • 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
  • 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 ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic