![]() |
Trying to upload files with PHP and Prototype AJAX
Hello there.
I have a problem i don´t seem to understand why it wont work out the way i intend it to. The only thing i can think of is that the headers or the upload data don´t get transfered correctly. I will show you 3 files that involves the problem: First my javascript that uses the Prototype Framwork. Code:
function AjaxUpload(MyUrl, MyDiv, TargetDiv)PHP Code:
This file is called by the JavaScript function mentioned. PHP Code:
Do you gurus have any tips ? :$ If there is odd words somewhere, it´s because im swedish ;) Thx in advance. /Eye |
To my knowledge, there is no way to pass that though ajax. Every "ajax" upload you see is really a hidden Iframe.
|
Like Village Idiot said, theres no way to pass file uploads though AJAX so you have to use a hidden iframe which submits the data, the sourcecode of this small script should help give you a clue ;)
AJAX File Upload |
Thx :)
I was afraid of that answer :) So ajax is currently just usable for sending data into an database or something other then uploading a file ? I say thanks again :) I will have to figure something else out :) /Eye |
You can use my ajax upload plugin for prototype, it allows you to upload multiple files and use any element as upload button.
|
Also, in order to be able to upload files to a server, you need to set the encoding type on the form to multipart/form-data:
Code:
<form action="..." method="post" enctype="multipart/form-data"> |
Lastly, your MIME data can easily be forged, I could upload literally anything to your server (show me where it is hosted and I will gladly prove it).
|
| All times are GMT. The time now is 04:28 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0