Advertisement
wellpe

Untitled

Sep 22nd, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. <?php
  2. // enviar o arquivo para pasta
  3.  
  4. if(isset($_FILES['arquivo'])) {
  5.  
  6. if(count($_FILES['arquivo']['tmp_name']) > 0) {
  7.  
  8. for($q=0;$q<count($_FILES['arquivo']['tmp_name']);$q++) {
  9.  
  10. $nomedoarquivo = md5($_FILES['arquivo']['name'][$q].time().rand(0,999)).'.pdf';
  11.  
  12. move_uploaded_file($_FILES['arquivo']['tmp_name'][$q], 'arquivos/'.$nomedoarquivo);
  13.  
  14.  
  15. $wcnx = "mysql:dbname=corec;host=localhost";
  16. $dbuser = "root";
  17. $dbpass = "";
  18.  
  19. try {
  20. $pdo = new PDO($wcnx, $dbuser, $dbpass);
  21.  
  22. $nome = $_POST['nome'];
  23. $areasubmissao = $_POST['areasubmissao'];
  24.  
  25. $sql = "INSERT INTO cadastros SET nome = '$nome', areasubmissao = '$areasubmissao', nomedoarquivo = '$nomedoarquivo'";
  26. $sql = $pdo->query($sql);
  27.  
  28. echo "cadastro INSERIDO: ".$pdo->lastInsertId();
  29.  
  30. } catch(PDOException $e) {
  31. echo "Falhou: ".$e->getMessage();
  32. }
  33. }
  34.  
  35. }
  36.  
  37. }
  38.  
  39. ?>
  40.  
  41.  
  42. formulario
  43.  
  44. <div style="padding:50px; width:400px; background-color:#ccc; margin:auto">
  45. <form method="POST" enctype="multipart/form-data" action="config.php">
  46.  
  47. Nome: <input type="text" name="nome" value="seu nome"><br>
  48. Área: <input type="text" name="areasubmissao" value="digite a area"><br><br>
  49.  
  50. Arquivo:<br/>
  51. <input type="file" name="arquivo[]" multiple /><br/><br/>
  52.  
  53. <input type="submit" value="Enviar Arquivos" />
  54.  
  55. </form>
  56. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement