|
Not logged in [Login - Register] |
You Are Not Registered Or Not Logged In |
Corsa Sport » Message Board » Off Day » Geek Day » PHP gurus » Post Reply
|
ed |
posted on 12th May 10 at 08:41 |
For starters it's not even AJAX. You couldn't use AJAX in that situation even if you wanted to. | |
xa0s |
posted on 11th May 10 at 23:49 |
quote: No, it's definitely complicating it... If he has to ask for help doing something simple like this then introducing Ajax as well isn't a great idea. :boggle: | |
Dom |
posted on 10th May 10 at 22:38 |
quote: Once you've moved the file (from temp directory to root or wherever), then simply echo out an IMG tag with the image in it, eg: echo "<IMG src=\"",$filelocation,"\">"; (commas on echos are fine by the way) If you already have a basic PHP upload then i wouldn't worry about AJAX or JQuery/Flash uploads, can always add them in afterwards if it will get your more marks. | |
ed |
posted on 10th May 10 at 13:30 |
It's hardly complicating it. The script is all in here give or take a few additions... http://valums.com/ajax-upload/ | |
xa0s |
posted on 10th May 10 at 13:27 |
Why complicate it with Ajax? When the file is submitted it changes page anyway so just display the image. The hard bit is already done... | |
ed |
posted on 10th May 10 at 12:17 |
There are two ways of doing it. Synchronously using pure PHP, so you'd upload the file then on page reload after the upload had commenced you would use some PHP to display the image. You could do it Asynchronously using Javascript. The script I suggested will do what you're trying to do, and in fact I have an avatar upload script which does exactly what you're trying to do. The user uploads their avatar, the upload script handles the upload along with the PHP stuff to do the file handling and when the upload is complete the PHP script returns some JSON to say that it's all worked and tells use the new filename. The upload script then uses that JSON message to figure out if something has gone wrong or if the pic has uploaded. If the pic has uploaded you use document.getelementbyid.('image_id').src= to change the src of the existing image to the new image. | |
AndyKent |
posted on 10th May 10 at 11:52 |
Can you not just write it yourself? | |
daymoon |
posted on 10th May 10 at 11:00 |
Sorry, maybe i wasnt clear. | |
Dom |
posted on 9th May 10 at 22:33 |
You can do a very basic file upload using the form file input (type='file') and then use $_FILES[] to save the uploaded file that you can recall (ie: display) later - http://www.tizag.com/phpT/fileupload.php | |
ed |
posted on 9th May 10 at 21:11 |
I use this script: http://valums.com/ajax-upload/ | |
daymoon |
posted on 9th May 10 at 20:54 |
Trying to make a simple website for my uni project and got to use php.. |