Select picture in order form

Wazz

No avatar

2010-06-10 18:52

How can I make, that users can add picture (upload from their computer) in order form and their picture will be than send to adminstration or on email?

» Quick.Cart v3.x

beholder

Avatar: beholder

2010-06-11 03:41

uploading picture and not displaying it on order form page should be no problem (I think). But sending it via email.. might not be easy. It's technically possible, though, some reprogramming is perhaps needed.

boboo

Avatar: boboo

2010-06-11 07:14

This is only an example.
To any existing template add a Form:
<form action="" method="post" id="kontaktl" enctype="multipart/form-data" onsubmit="this.tarcze_laden.value='Please wait...';">
<table>
<tr>
<td class="sendfile" >File on local PC: <input type="file" name="datei" class="inputf"></td>
<td class="sendfile" input type="submit" value="Upload file" class="submit" name="upload"></td>
</tr>
</table>
</form>

Then add a few lines code to (for example /templates/themes/default.php)
if ( isset ( $_POST['upload'] ) ) {
$dateityp = GetImageSize($_FILES['datei']['tmp_name']);
$folder = "myfolderforupload/";
$sHome = "myEmail@domain.de";
$header = 'MIME-Version: 1.0' . "\n" . 'Content-type: text/plain; charset=UTF-8'. "\n" . 'From: <' . $sHome . ">\n";
$sBetreff = "A file has been uploaded";
if ( $dateityp[2] != 0 ){
if($_FILES['datei']['size'] < 1048576) {
move_uploaded_file($_FILES['datei']['tmp_name'], $ordner.$_FILES['datei']['name']);
$sTekst = $_FILES['datei']['name'];
@mail($sHome, $sBetreff, $sTekst, $header);
$content .= $oTpl->tbHtml( 'messages.tpl', 'SENDFILE_OK' ).$_FILES['datei']['name'];
}
else {
$content .= $oTpl->tbHtml( 'messages.tpl', 'NOT_SENDFILE_BYTE' );
}
}
else {
$content .= $oTpl->tbHtml( 'messages.tpl', 'NOT_SENDFILE_TYPE' );
}

}

If you want, that the uploading user should get a message on the site, than create new blocks in message.tpl
and give them the example names (SENDFILE_OK, NOT_SENDFILE_BYTE, NOT_SENDFILE_TYPE)

In the line: if($_FILES['datei']['size'] < 1048576) {
you can determine the maximum size of file (in bytes). The example above is set to 1MB.
in this line: if ( $dateityp[2] != 0 ){
you can determine the type of file (pictures, or others)

More details you will find here:
http://php.net/manual/en/features.file-upload.php

Hope, that will help you a bit.

http://skupienie.kimla.de/?software-quickcart,106

boboo

Avatar: boboo

2010-06-11 07:25

Important:
the form must have a property: enctype="multipart/form-data"
and you have to create a folder on your server (in this example: "myfolderforupload").
And in this solution you will get the email message, that a file has been uploaded (with the name of file), you will NOT get the file as an attachment.
You have to take it manually from the folder.

http://skupienie.kimla.de/?software-quickcart,106

boboo

Avatar: boboo

2010-06-11 07:27

Uppps,
and in the line:
move_uploaded_file($_FILES['datei']['tmp_name'], $ordner.$_FILES['datei']['name']);

change $ordner to $folder

;-)

http://skupienie.kimla.de/?software-quickcart,106

beholder

Avatar: beholder

2010-06-12 00:37

Damn, I just realized what Wizz is up to... I was tired before and didn't understand it in the right way. Must think about it more, will write here if something occurs to me.

Back to top
about us | contact