Michdd Posted May 18, 2009 Share Posted May 18, 2009 Is it possible to upload images using Php and Ajax? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 18, 2009 Share Posted May 18, 2009 Not really, the problem is javascript can't control the file input (for security reasons), however a workaround would be to put the form in a iframe allows you to stay on the same page. if your also aiming for a processbar then again no luck php can't read how much data has been processed, a workaround for this is CGI script. and a small ajax to read the data recieved Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted May 18, 2009 Share Posted May 18, 2009 if your also aiming for a processbar then again no luck php can't read how much data has been processed http://wiki.php.net/rfc/session_upload_progress Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 18, 2009 Share Posted May 18, 2009 I was going to say they have changed that in PHP 6, but looks like i don't have to now lol Quote Link to comment Share on other sites More sharing options...
Michdd Posted May 18, 2009 Author Share Posted May 18, 2009 The main point would be to upload/process it without reloading the page. I will have 2 methods of uploading images, from a URL, or from your computer. The URL one works fine because I just send the URL of the input file through ajax to another php file for processing. But this obviously won't work for uploading from a computer. I was also thinking about using an iframe with 0 width/height/border but how would I get it to submit the information to the iframe? If I could do it using GET variables then I could just change the source of the iframe.. but since it'll be using post, I'm a bit confused. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 18, 2009 Share Posted May 18, 2009 Just create a form then view that from the iframe. Quote Link to comment Share on other sites More sharing options...
Michdd Posted May 18, 2009 Author Share Posted May 18, 2009 Just create a form then view that from the iframe. Are there any other options? Because the way I have it setup the form will be in a table.. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 18, 2009 Share Posted May 18, 2009 Their are other ways but they get a little bit complex, the iframe will still work in a table take a look at this (it basically used javascript to put the iframe in place) Quote Link to comment Share on other sites More sharing options...
Michdd Posted May 18, 2009 Author Share Posted May 18, 2009 Their are other ways but they get a little bit complex, the iframe will still work in a table take a look at this (it basically used javascript to put the iframe in place) I was actually just looking at the same thing myself. Thanks. Quote Link to comment Share on other sites More sharing options...
Michdd Posted May 18, 2009 Author Share Posted May 18, 2009 I thought I had everything figured out.. But isn't it supposed to send the information to the file? I tried echoing something out like: echo $_FILES['userfile']['name']; Where the form says: <label for="file">File:</label> <input type="file" name="userfile" id="file" /> But it's not sending the information.. Edit: I forgot: enctype="multipart/form-data" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.