Created
July 29, 2011 01:51
-
-
Save juandazapata/1112976 to your computer and use it in GitHub Desktop.
AS2 upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// array with filenames to be sent as attachment | |
$files = array("attachments_emails/foto1.jpg","attachments_emails/foto2.jpg","attachments_emails/foto3.jpg"); | |
if(isset($_POST["nombre"]) && isset($_POST["telefono"]) && isset($_POST["email"]) && isset($_POST["url_fotos"]) && isset($_POST["direccion"]) && isset($_POST["barrio"]) && isset($_POST["ciudad"]) && isset($_POST["rut"]) && isset($_POST["eps"]) && isset($_POST["arp"])): | |
$fecha = date("d-M-y H:i"); | |
$to = "registro@oncegroup.com.co"; | |
$subject = "Alguien desea trabajar en Once Group"; | |
$nombre= $_POST["nombre"]; | |
$email= $_POST["email"]; | |
$from = $email; | |
$telefono= $_POST["telefono"]; | |
$direccion= $_POST["direccion"]; | |
$barrio= $_POST["barrio"]; | |
$ciudad= $_POST["ciudad"]; | |
$rut= $_POST["rut"]; | |
$eps= $_POST["eps"]; | |
$arp= $_POST["arp"]; | |
$message = "<strong>SE HA RECIBIDO UN EMAIL PARA TRABAJAR CON NOSOTROS DESDE EL SITIO WEB </strong><br /><br /><br />"; | |
$message = $message."<strong>Nombre: </strong>".$nombre."<br /><br />"; | |
$message = $message."<strong>Email: </strong>".$email."<br /><br />"; | |
$message = $message."<strong>Teléfono: </strong>".$telefono."<br /><br />"; | |
$message = $message."<strong>Ciudad: </strong>".$ciudad."<br /><br />"; | |
$message = $message."<strong>Dirección: </strong>".$direccion."<br /><br />"; | |
$message = $message."<strong>Barrio: </strong>".$barrio."<br /><br />"; | |
$message = $message."<strong>Número de RUT: </strong>".$rut."<br /><br />"; | |
$message = $message."<strong>Tiene EPS: </strong>".$eps."<br /><br />"; | |
$message = $message."<strong>Tiene ARP: </strong>".$arp."<br /><br />"; | |
$message = $message."<strong>Fecha de Envío: </strong>".$fecha; | |
$headers = "From: $from"; | |
// boundary | |
$semi_rand = md5(time()); | |
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; | |
// headers for attachment | |
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; | |
// multipart boundary | |
$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; | |
$message .= "--{$mime_boundary}\n"; | |
// preparing attachments | |
for($x=0;$x<count($files);$x++){ | |
$file = fopen($files[$x],"rb"); | |
$data = fread($file,filesize($files[$x])); | |
fclose($file); | |
$data = chunk_split(base64_encode($data)); | |
//$data = chunk_split(base64_encode(file_get_contents(''.$files[$x]))); | |
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$x]\"\n" . | |
"Content-Disposition: attachment;\n" . " filename=\"$files[$x]\"\n" . | |
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; | |
$message .= "--{$mime_boundary}\n"; | |
} | |
// send | |
$ok = @mail($to, $subject, $message, $headers); | |
echo $ok ?"&estatus=ok&":"&estatus=failed"; | |
if (file_exists("attachments_emails/foto1.jpg")) | |
{ | |
unlink("attachments_emails/foto1.jpg"); | |
} | |
if (file_exists("attachments_emails/foto2.jpg")) | |
{ | |
unlink("attachments_emails/foto2.jpg"); | |
} | |
if (file_exists("attachments_emails/foto3.jpg")) | |
{ | |
unlink("attachments_emails/foto3.jpg"); | |
} | |
endif; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import flash.net.FileReference; | |
//*********************************** | |
// File upload | |
//*********************************** | |
_root.contenidoContacto.btnEnviar._visible = false; | |
var subida_completa1 = false; | |
var subida_completa2 = false; | |
var subida_completa3 = false; | |
function validar_subida_completa() | |
{ | |
if(subida_completa1 && subida_completa2 && subida_completa3) | |
{ | |
_root.contenidoContacto.btnEnviar._visible = true; | |
} | |
} | |
var arrTypes:Array = new Array(); | |
var objTypes:Object = new Object(); | |
objTypes.description = "Images (*.jpg, *.jpeg)"; | |
objTypes.extension = "*.jpg; *.jpeg"; | |
arrTypes.push(objTypes); | |
function subir1() | |
{ | |
var listUpload:Object = new Object(); | |
var fileUpload:FileReference = new FileReference(); | |
fileUpload.addListener(listUpload); | |
listUpload.onSelect = function(file) { | |
_root.contenidoContacto.url1_txt.text = file.name; | |
fileUpload.upload("upload.php?action=upload&numero=1"); | |
} | |
listUpload.onProgress = function(file, bytesLoaded, bytesTotal):Void { | |
var porcentaje:String = Math.round(bytesLoaded*100/bytesTotal) + "%"; | |
_root.contenidoContacto.url1_txt.text = file.name + " (" + porcentaje + ")"; | |
} | |
listUpload.onComplete = function(file:FileReference):Void { | |
subida_completa1 = true; | |
validar_subida_completa(); | |
} | |
_root.contenidoContacto.btnExplorar1.onRelease = function() { | |
fileUpload.browse(arrTypes); | |
} | |
} | |
function subir2() | |
{ | |
var listUpload:Object = new Object(); | |
var fileUpload:FileReference = new FileReference(); | |
fileUpload.addListener(listUpload); | |
listUpload.onSelect = function(file) { | |
_root.contenidoContacto.url2_txt.text = file.name; | |
fileUpload.upload("upload.php?action=upload&numero=2"); | |
} | |
listUpload.onProgress = function(file, bytesLoaded, bytesTotal):Void { | |
var porcentaje:String = Math.round(bytesLoaded*100/bytesTotal) + "%"; | |
_root.contenidoContacto.url2_txt.text = file.name + " (" + porcentaje + ")"; | |
} | |
listUpload.onComplete = function(file:FileReference):Void { | |
subida_completa2 = true; | |
validar_subida_completa(); | |
} | |
_root.contenidoContacto.btnExplorar2.onRelease = function() { | |
fileUpload.browse(arrTypes); | |
} | |
} | |
function subir3() | |
{ | |
var listUpload:Object = new Object(); | |
var fileUpload:FileReference = new FileReference(); | |
fileUpload.addListener(listUpload); | |
listUpload.onSelect = function(file) { | |
_root.contenidoContacto.url3_txt.text = file.name; | |
fileUpload.upload("upload.php?action=upload&numero=3"); | |
} | |
listUpload.onProgress = function(file, bytesLoaded, bytesTotal):Void { | |
var porcentaje:String = Math.round(bytesLoaded*100/bytesTotal) + "%"; | |
_root.contenidoContacto.url3_txt.text = file.name + " (" + porcentaje + ")"; | |
} | |
listUpload.onComplete = function(file:FileReference):Void { | |
subida_completa3 = true; | |
validar_subida_completa(); | |
} | |
_root.contenidoContacto.btnExplorar3.onRelease = function() { | |
fileUpload.browse(arrTypes); | |
} | |
} | |
subir1(); | |
subir2(); | |
subir3(); | |
//*********************************** | |
// File upload end | |
//*********************************** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ($_GET["action"] == "upload") { | |
$archivo = $_FILES["Filedata"]['name']; | |
$numero = $_GET["numero"]; | |
$prefijo = substr(md5(uniqid(rand())),0,6); | |
if ($archivo != "") { | |
$destino = "attachments_emails/foto".$numero.".jpg"; | |
move_uploaded_file($_FILES['Filedata']['tmp_name'], $destino); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment