mardi 25 octobre 2016

how to upload an image to server directory in php using temporary link

<div class="col-md-12" onclick=imgAccepter()>  
<form action="UploadImg.php" method="POST" enctype="multipart/form-data">                               
<input id="profile-image-upload" class="hidden" type="file" name="img"  />   
<img id="image" src="" />                   



function imgAccepter(){
    document.getElementById("profile-image-upload").click();
}

$('#profile-image-upload').change( function(event) {
var tempPath = URL.createObjectURL(event.target.files[0]);
$("#image").attr('src',URL.createObjectURL(event.target.files[0]));

hi guys I uploaded a image file to my website using this code and it gives me a temp path like blog/localhost:xxxxx-xxxxx-xxxxxxxxxx but I'm having issues to save this image to the server directory. As we can't get the full path in modern browsers i can't save the image using this temporary link. help me where I'm doing a mistake

$img_ff = $_POST["path"];
$user = $_POST["name"];
$id = $_POST["id"];
$dst_img= $user.$id;
$dst_path="../images";    
$dst_cpl = $dst_path . $dst_img;

move_uploaded_file($_FILES[$img_ff]['tmp_name'], $dst_cpl);




Aucun commentaire:

Enregistrer un commentaire