0

I have a classic form and an upload image input that allows visitors to enter details and one image.

<input type="text" id="first_name" name="first_name" maxlength="50">
<input type="file" id="image" name="image">

currently I store images on the client server and send just the image URL to the client email, but recently the folder reached the limit of 10MB and no further images uploads were possible and further emails failed submission too.
I tried for a long time to somehow send the form with an uploaded image the the client email, without storing it server side but with no success. Googled all around and tried lot of suggestions - I was just able to send the form but with no image attached to it. What can I do?

Ginnani
  • 325
  • 1
  • 5
  • 19

2 Answers2

1

It is not possible to attach a file to an e-mail without first storing it on the server.

You may consider using a service such as Amazon S3 to host the files. That way, you don't have to handle the files and you can still e-mail the URLs, which makes everyone happier.

Alternatively, you may be able to find a service such as ImageShack that provides an API to upload pictures to.

Good luck!

David
  • 3,831
  • 2
  • 28
  • 38
  • +1 Thanks for your fast answer! The client is concerned about privacy, and I was trying to not pay some 3rd parties for upload services... – Ginnani Aug 05 '12 at 22:21
  • All I can say is find a better server :/ 10MB is an extremely small amount of space. – David Aug 05 '12 at 22:25
  • Without any extra information, I'm not sure. Amazon EC2 offers a free 612MB RAM server free (not sure how many gigs of storage) for one year. If you have experience with Linux servers, you may want to give it a try. – David Aug 05 '12 at 22:28
  • Thank you! I'll leave this topic opened a bit before accepting. Thanks! I'm really out of imagination how to solve this. – Ginnani Aug 05 '12 at 22:30
1

You should be able to get the binary contents of the image with file_get_contents($image) using the tmp location when you submit the form and then use that data in the e-mail. The approach to display in the e-mail will vary depending on if you are using html e-mails or not.

This link may help php: recreate and display an image from binary data

Community
  • 1
  • 1
jimhartford
  • 101
  • 2