Apr
29
2010
0

Subir archivo al servidor desde formulario y enviar email a usuario con enlace (Drupal)

El archivo se llama a sí mismo para procesar el archivo enviado por el usuario desde el formulario y enviar un email con un enlace al mismo. Con algunas modificaciones se podrá usar en cualquier entorno, no necesariamente en Drupal.

  1. <?php if ( !empty($_POST) ) {
  2. if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $_SERVER['DOCUMENT_ROOT']."/sites/default/files/user_form_uploads/".$_FILES['uploadedfile']['name'])) {
  3. echo "The file has been uploaded";
  4. }
  5. echo "Thank you for sending your file.";
  6. $emailadd = 'Recipient.org <recipient@recipient.org>';
  7. $text = "Alguien envió un archivo desde la web.";
  8. $space = '';
  9. $line = '
  10. ';
  11. foreach ($_POST as $key => $value){
  12. if ( !empty($value) ) {
  13. if ($key!='submit' ) {
  14. $key = str_replace("_", " ", $key);
  15. $text .= "<strong>".$key . ":</strong> " . $value . "";
  16. $space = ' ';
  17. }
  18. if ($key=='Email') {
  19. $emailapplicant=$value;
  20. }
  21. }
  22. }
  23. $text .= $line."You can download the file uploaded by the user <a href='http://www.ejemplo.com/sites/default/files/user_form_uploads/".$_FILES['uploadedfile']['name']."'>clicking here</a>.";
  24. mail($emailadd, "Someone sent a file", $text, "From: ".$emailadd."\r\nContent-type: text/html\r\nContent-type: text/html\r\n");
  25. } ?>
  26. <form id="apply_aff_form" method="post" action="thispage.php" class="formular" enctype="multipart/form-data">
  27. <fieldset>
  28. <input name="uploadedfile" id="uploadedfile" type="file" size="46" />
  29. <input id="submit" type="submit" name="submit" value="Submit" class="submit" />
  30. </fieldset>
  31. </form>
  32.  
No me interesaNo está malBienÚtilMuy bien, muy útil (No Ratings Yet)
Loading ... Loading ...
Post de cabezaBomba en la(s) categoría(s): Desarrollo Web,Drupal,PHP,formularios | Tags: , , , , , , , , , , , , ,

Creative Commons License
Webcidentes by Alejandro Garcia is licensed under a Creative Commons Reconocimiento-Compartir bajo la misma licencia 3.0 España License.
Based on a work at www.cabezabomba.com.