AUS/NZ
PC PS XBOX GIRL TV STORE
Login:
? Sign Up!
Powered by AMD
E-Sports Communities & Competitions

upload field - sending to email

Started by inzid on 7:31am 10/2/12. 231 views and 5 posts, 0 users reading, last post by Foul.

Currently reading (0 users):
OP
Joined: 5/5/07
Posts: 283
Defaults: AU - PC: Call of Duty
using Firefox 10.0
Rep:
46%
Hi does anybody know any scripts that you can attach files to a contact form and once you click submit it sends the attachment to your email?


I've been trying to get it to work on a script I got and trying to implement it to my HTML contact form.


here is the instructions that I have uploaded with a working example (came with the instructions)

http://callumpirie.com/dev/uploader/


I am trying to implement it to this website (click the Yes radio button to view more of the form)

http://callumpirie.com/dev/uploader/test2.php



heres the code on the test2.php page.


CODE:
<?php if(!empty($uploaded_files)): ?>
<ul id="success">
<?php foreach($uploaded_files as $k=>$v): ?>
<li><?php echo $v; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>

<?php if(isset($errors)): ?>
<ul id="errors">
<?php foreach($errors as $k=>$v): ?>
<li><?php if(!is_numeric($k)){ echo $k.': ';} echo $v; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>

<div class='input file'>
<label>Select File: </label>
<input type='file' name='file[]' />
<a href='#' class='add_another_file_input hide'>
<img src='./img/add.png' alt='Add Icon' />
</a>
</div>
<div class='input buttons'>
<button type='submit' name='upload' id='upload'>Upload</button>
</div>
</fieldset>
<?php //pr($upload); ?>

Unless anybody has a better or easier script any help would be awesome.

Thanks.
Posted on Friday, 10th February 2012
never shake a baby
Joined: 8/7/09
Posts: 2,374
Defaults: AU - PC: Counter-Strike Source
using Chrome 19.0
Rep:
58%
Game Administrator
No longer a CSS admin, please stop PMing me.
Joined: 8/8/10
Posts: 10
Defaults: AU - PC: Dota 2
using Safari 7534.48
Rep:
27%
What is it that you are having trouble with? Your form is missing enctype='multipart/form-data' unless I read the source wrong.

If you're just having trouble with the attachment part you just need to go and familiarise yourself with mime types and mime boundaries.

www.texelate.co.uk/blog/send-email-attachment-with-php/ Like this but instead of reading from a directory you would be reading from the uploaded files array.
Posted on Friday, 10th February 2012
OP
Joined: 5/5/07
Posts: 283
Defaults: AU - PC: Call of Duty
using Firefox 10.0
Rep:
46%
Yeh having problems with the whole attachment part
Posted on Friday, 10th February 2012
never shake a baby
Joined: 8/8/10
Posts: 10
Defaults: AU - PC: Dota 2
using Safari 7534.48
Rep:
27%
Quote from inzid on the 10th of February 2012:
Yeh having problems with the whole attachment part

Quote:
Step 6:
The PHPMailer class has been included and the Upload class updated so that uploaded files can now be emailed as attachements. Simply change the email details (e.g. From, To, Subject, Body) and the email will be sent automatically. The script will show an error if the email failed.

So does it give you an error? If not check your error log and there will be something in there indicating where it ****ed up. From the page you linked you really shouldn't have to write anything other than changing some variables to adapt it to your site.
Posted on Friday, 10th February 2012
 

upload field - sending to email