Jump to content

Recommended Posts

I'm trying to send a file over to a PHP script using GET with AJAX. Ajax is working fine however is there a way to send

an entire file over to PHP? This is since all I know thus far is we send strings via GET.

 

 

<script type="text/javascript">
var Load = function() {   
     var image = document.getElementById("img").value // here I could get the image value, i.e. the file name

     // sending with ajax
     XmlHttpRequest.open("GET", "server.php?id=17&image=" +image, true);
     ........ rest of ajax code
     // I know from the above all that would be sent would be the name, But is there a way to send the entire file so PHP could process?

    return false;
};
</script>
</head>
<body>

<form action=# method="post" onsubmit="return Load();">
    <input type="file" name="img" id="img">
    <input type="submit" value="Upload">
</form>

 

 

Could you clarify what you mean by upload it?

 

If I was using just PHP and HTML, I would post the HTML page onto the PHP page and upload the file directly.

 

I'm trying to use AJAX to do the same. The only problem is either directly or indirectly uploading it.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.