Michdd Posted May 18, 2009 Share Posted May 18, 2009 Is it possible to upload images using Php and Ajax? Link to comment https://forums.phpfreaks.com/topic/158528-solved-ajax-php/ 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 Link to comment https://forums.phpfreaks.com/topic/158528-solved-ajax-php/#findComment-836099 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 Link to comment https://forums.phpfreaks.com/topic/158528-solved-ajax-php/#findComment-836104 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 Link to comment https://forums.phpfreaks.com/topic/158528-solved-ajax-php/#findComment-836107 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. Link to comment https://forums.phpfreaks.com/topic/158528-solved-ajax-php/#findComment-836119 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. Link to comment https://forums.phpfreaks.com/topic/158528-solved-ajax-php/#findComment-836121 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.. Link to comment https://forums.phpfreaks.com/topic/158528-solved-ajax-php/#findComment-836126 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) Link to comment https://forums.phpfreaks.com/topic/158528-solved-ajax-php/#findComment-836134 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. Link to comment https://forums.phpfreaks.com/topic/158528-solved-ajax-php/#findComment-836137 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" Link to comment https://forums.phpfreaks.com/topic/158528-solved-ajax-php/#findComment-836150 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.