0

First of all i'm beginning to say that i am new to Ajax and PHP so im asking if someone could help me out.

I am making a way where users can upload an image inside a frame for images, it works fine and if the user tries to upload the image to a PDF (with DOMPDF) it doesn't upload the image it self.

in short, it needs to be able to upload the image to a file called 'uploads'


Jquery(AJAX)

(the form.save is a form tag with the name save inside of it)

log($(e.target).closest('form.save')[0],$(('FormData')[2]));

           $.ajax({
        url: 'images.php',         // Url to which the request is send
        type: 'POST',             // Type of request to be send, called as method
        data: $(e.target).closest('form.save'), // Data sent to server, a set of key/value pairs (i.e. form fields and values)
        contentType: false,       // The content type used when sending data to the server.
        cache: false,             // To unable request pages to be cached
        processData:false,        // To send DOMDocument or non processed data file it is set to false
        success: function(data)   // A function to be called if request succeeds
        {
        $('#loading').hide();
        $('#message').html(data);
        }
        });

PHP

<?php  
    foreach($_FILES["images"]["error"] as $key => $error) {
      if ($error == UPLOAD_ERR_OK) {
        $name = $_FILES["images"]["name"][$key];
        move_uploaded_file( $_FILES["images"]["tmp_name"][$key], "uploads/" . $_FILES['images']['name'][$key]);
      }
    }

        echo "<h2>Successfully Uploaded Images</h2>";
?> 

Thanks in advance!,
got any questions? I'm happy to hear them.

Dennis Offinga
  • 85
  • 1
  • 1
  • 9

0 Answers0