Problema con formulario
Publicado por Rodrigo Solis (3 intervenciones) el 23/11/2007 16:27:09
Hola amigos
Tengo un problemita que me ha quitado un poco el sueño tengo un formulario que permite subir archivos mi hosting y yo he realizado algo para que al momento de subir el archivo mande tambien informacion del archivo por medio de un correo electronico, el problema es que al utiliza la funcion mail solo me permite 4 campos,
ejemplo:
mail($sendTo, $subject, $message, $file);
ahora bien deseo agragar mas campos al cuerpo del mensaje tales como nombre, cantidad y algun comentario por el momento llevo este codigo:
<?php
$status = "";
if ($_POST["action"] == "upload") {
// aca obtengo los datos del archivo a subir
$tamano = $_FILES["archivo"]['size'];
$tipo = $_FILES["archivo"]['type'];
$archivo = $_FILES["archivo"]['name'];
$prefijo = substr(md5(uniqid(rand())),0,6);
if ($archivo != "") {
// aca guardo el archivo en una carpeta predeterminada
$destino = "files/".$prefijo."_".$archivo;
if (copy($_FILES['archivo']['tmp_name'],$destino)) {
$status = "File Uploaded: <b>".$archivo."</b>";
$sendTo = "[email protected]";
$subject = "Uploaded File Information";
$message = $_POST['name_cs'];
$file = $_FILES["archivo"]['name'];
mail($sendTo, $subject, $message, $file, $message2);
} else {
$status = "Error al subir el archivo";
}
} else {
$status = "Error al subir archivo";
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Send File</title>
<link href="estilo.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.Estilo1 {color: #000000}
.Estilo2 {color: #2386D6}
.Estilo3 {color: #FF0000}
-->
</style></head>
<body>
<table width="716" height="749" border="0" align="center" cellpadding="0" cellspacing="0" background="images/background_send.png">
<tr>
<td width="42" height="40" rowspan="3" class="titulo"> </td>
<td width="674" height="184" class="titulo"><img src="images/spacer2.gif" width="8" height="179">
<script language="javascript" src="untitledmenu1.js"></script> </td>
</tr>
<tr>
<td height="86" class="titulo"><img src="images/spacer2.gif" width="8" height="86"></td>
</tr>
<tr>
<td height="23" class="titulo">Upload files</td>
</tr>
<tr>
<td height="29" class="text"> </td>
<td class="text Estilo1">Please select the file to upload</td>
</tr>
<tr>
<form action="upload.php" method="post" enctype="multipart/form-data">
<td height="84" class="text"> </td>
<td valign="top" class="text"><p>
File:
<input name="archivo" type="file" class="casilla" id="archivo" size="35" />
<br>
<label>Name
<input type="text" name="name_cs" id="name_cs">
</label>
<br>
<label>Quantity
<input type="text" name="quantity" id="quantity">
</label>
<br>
<label>Comments
<textarea name="comments" id="comments" cols="45" rows="5"></textarea>
</label>
</p>
<p>
<input name="enviar" type="submit" class="boton" id="enviar" value="Upload File" />
<input name="action" type="hidden" value="upload" />
<br>
<span class="Estilo3">Max Files Size 100MB</span></p></td>
</form>
</tr>
<tr>
<td height="39" class="text" style="color:#990000"> </td>
<td class="text" style="color:#990000"><span class="text" style="color:#990000"><?php echo $status; ?></span></td>
</tr>
<tr>
<td height="30" class="subtitulo"> </td>
<td height="30" class="subtitulo Estilo2"> </td>
</tr>
<tr>
<td rowspan="3" class="infsub"> </td>
<td class="infsub"> </td>
</tr>
<tr>
<td class="infsub"> </td>
</tr>
<tr>
<td class="infsub"> </td>
</tr>
</table>
<div align="center"></div>
</body>
</html>
Bueno por la ayuda muy agradecid
Tengo un problemita que me ha quitado un poco el sueño tengo un formulario que permite subir archivos mi hosting y yo he realizado algo para que al momento de subir el archivo mande tambien informacion del archivo por medio de un correo electronico, el problema es que al utiliza la funcion mail solo me permite 4 campos,
ejemplo:
mail($sendTo, $subject, $message, $file);
ahora bien deseo agragar mas campos al cuerpo del mensaje tales como nombre, cantidad y algun comentario por el momento llevo este codigo:
<?php
$status = "";
if ($_POST["action"] == "upload") {
// aca obtengo los datos del archivo a subir
$tamano = $_FILES["archivo"]['size'];
$tipo = $_FILES["archivo"]['type'];
$archivo = $_FILES["archivo"]['name'];
$prefijo = substr(md5(uniqid(rand())),0,6);
if ($archivo != "") {
// aca guardo el archivo en una carpeta predeterminada
$destino = "files/".$prefijo."_".$archivo;
if (copy($_FILES['archivo']['tmp_name'],$destino)) {
$status = "File Uploaded: <b>".$archivo."</b>";
$sendTo = "[email protected]";
$subject = "Uploaded File Information";
$message = $_POST['name_cs'];
$file = $_FILES["archivo"]['name'];
mail($sendTo, $subject, $message, $file, $message2);
} else {
$status = "Error al subir el archivo";
}
} else {
$status = "Error al subir archivo";
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Send File</title>
<link href="estilo.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.Estilo1 {color: #000000}
.Estilo2 {color: #2386D6}
.Estilo3 {color: #FF0000}
-->
</style></head>
<body>
<table width="716" height="749" border="0" align="center" cellpadding="0" cellspacing="0" background="images/background_send.png">
<tr>
<td width="42" height="40" rowspan="3" class="titulo"> </td>
<td width="674" height="184" class="titulo"><img src="images/spacer2.gif" width="8" height="179">
<script language="javascript" src="untitledmenu1.js"></script> </td>
</tr>
<tr>
<td height="86" class="titulo"><img src="images/spacer2.gif" width="8" height="86"></td>
</tr>
<tr>
<td height="23" class="titulo">Upload files</td>
</tr>
<tr>
<td height="29" class="text"> </td>
<td class="text Estilo1">Please select the file to upload</td>
</tr>
<tr>
<form action="upload.php" method="post" enctype="multipart/form-data">
<td height="84" class="text"> </td>
<td valign="top" class="text"><p>
File:
<input name="archivo" type="file" class="casilla" id="archivo" size="35" />
<br>
<label>Name
<input type="text" name="name_cs" id="name_cs">
</label>
<br>
<label>Quantity
<input type="text" name="quantity" id="quantity">
</label>
<br>
<label>Comments
<textarea name="comments" id="comments" cols="45" rows="5"></textarea>
</label>
</p>
<p>
<input name="enviar" type="submit" class="boton" id="enviar" value="Upload File" />
<input name="action" type="hidden" value="upload" />
<br>
<span class="Estilo3">Max Files Size 100MB</span></p></td>
</form>
</tr>
<tr>
<td height="39" class="text" style="color:#990000"> </td>
<td class="text" style="color:#990000"><span class="text" style="color:#990000"><?php echo $status; ?></span></td>
</tr>
<tr>
<td height="30" class="subtitulo"> </td>
<td height="30" class="subtitulo Estilo2"> </td>
</tr>
<tr>
<td rowspan="3" class="infsub"> </td>
<td class="infsub"> </td>
</tr>
<tr>
<td class="infsub"> </td>
</tr>
<tr>
<td class="infsub"> </td>
</tr>
</table>
<div align="center"></div>
</body>
</html>
Bueno por la ayuda muy agradecid
Valora esta pregunta


0