Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <form enctype="multipart/form-data" class="form-img" method="POST">
  2. <div class="row" style="margin: 0px; font-size: 18px;">
  3. <div class="col-md-4">
  4. <img width="100%" height="auto" src="fotos/<?php echo $_SESSION['logo']; ?>"><br>
  5. </div>
  6. <div class="col-md-8">
  7. <label style="display: block;">Seleccione una imagen de perfil:</label>
  8. <div hidden><input name="image" type="file"></div>
  9. <div class="btn-only blue upload" style="margin: 0px;">Buscar</div>
  10. <span class="img-status"></span>
  11. </div>
  12. </div><hr>
  13. </form>
  14.  
  15. $(".upload").on("click", function(){
  16. $("[name=image]").trigger("click");
  17. });
  18. $("[name=image]").on("change", function(){
  19. $.ajax({
  20. url: "functions/cambiar_imagen.php",
  21. type: "post",
  22. data: $(".form-img").serialize(),
  23. success: function(e){
  24. alert(e);
  25. }
  26. });
  27. });
  28.  
  29. <?php
  30. session_start();
  31. include("serverconfig.php");
  32. include("codificar_clave.php");
  33. include("log.php");
  34.  
  35. $target_path = "../fotos/";
  36. $target_path = $target_path.basename($_FILES["image"]["name"]);
  37. $temp_path = $_FILES["image"]["tmp_name"];
  38.  
  39. if(move_uploaded_file($temp_path, $target_path)){
  40. echo "El archivo ".basename($temp_path). " ha sido subido";
  41. } else {
  42. echo "Ha ocurrido un error, trate de nuevo!";
  43. }
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement