Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
Uploading images without reloading page
Old 01-08-2008, 02:04 AM Uploading images without reloading page
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Hi!

I need to be able to upload images without reloading the entire page. I already know how to upload files via HTTP, but I need help with the other part.

I have a form with some fields, where it should also be possible to add images. When selecting a file and pressing 'Upload' I need the file to be uploaded without submiting the entire form. The images will then be added to the form in some way, and when finally submitting the form the data (including the uploaded files) will be processed and stored in a database.

Thanks
lizciz
lizciz is offline
View Public Profile Visit lizciz's homepage!
 
 
Register now for full access!
Old 01-08-2008, 03:07 AM Re: Uploading images without reloading page
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
You do not understand what is http request and http response. It is impossible to upload a file to server without submitting some form. The trick is that you *do not see* that form being submitted, but still it is submitted. It is called AJAX. Your browser sends the file by submitting some hidden form, the file is processed on server with regular file uploads mechanism and then server returns some data which is processed by some javascript object which called hiddenform.submit() and should now represent the received data to user.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
View Public Profile Visit mtishetsky's homepage!
 
Old 01-08-2008, 04:46 AM Re: Uploading images without reloading page
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Ok, so basically I can put the upload field in a separate form and submit it "behind the scenes", while the main form is still not submited?

I don't know anything about AJAX basically. Know a good place to start?
lizciz is offline
View Public Profile Visit lizciz's homepage!
 
Old 01-08-2008, 03:36 PM Re: Uploading images without reloading page
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
You can perform file uploads asynchronously - without an apparent refresh but it is not true Ajax. The javascript XMLHttpRequest object central to AJAX cannot access the clients file system for security reasons.

Can be done by using a hidden iframe and posting the form to the iframe. It has the same effect as Ajax.

Couple of good scripts one with a progress bar

http://php5.bluga.net/UploadProgressMeter/demo.php
http://thecodecentral.com/2007/09/04...-yuis-approach
maxxximus is offline
View Public Profile
 
Old 01-09-2008, 06:01 AM Re: Uploading images without reloading page
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Thanks for your awnsers. I've read a bit about AJAX now and searched for some scripts. Instead of letting some AJAX upload the images, which you pointed out is not possible due to security risks, It seems I can get the XMLHttpRequest object to send the information from a file input field to a php file which will make the upload. The php file could then return some value in order for me to know that the upload went ok, and a hidden field would be added in the form holding the uploaded image path, so that it can be stored in a database.

I think this is the aproach they used in seccond link you posted maxxximus.
Just one last question, what does asynchronously mean?
lizciz is offline
View Public Profile Visit lizciz's homepage!
 
Old 01-11-2008, 05:14 PM Re: Uploading images without reloading page
COLD_FIRE's Avatar
Junior Talker

Posts: 3
Trades: 0
Not sure if this will help you, but I prefer the method with flash uploader and one php script behind the scene, because it's cute ;-)

Flash can show you how big is the file, percentage of completion and you don't have to play with iframes and forms etc, only flash and one php script.

see here http://www.flash-db.com/Tutorials/upload/
__________________

Please login or register to view this content. Registration is FREE
- IT Telework Network

Please login or register to view this content. Registration is FREE
- Teen Girls And Affiliate Programs

Last edited by COLD_FIRE; 01-11-2008 at 05:20 PM..
COLD_FIRE is offline
View Public Profile
 
Old 01-12-2008, 04:59 AM Re: Uploading images without reloading page
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Funny you should say that, just yesterday I finally got my script working, using flash and one script file handling the uploads.
I'm using 'MultiPow Upload', it's really great.
lizciz is offline
View Public Profile Visit lizciz's homepage!
 
Old 01-12-2008, 08:26 AM Re: Uploading images without reloading page
COLD_FIRE's Avatar
Junior Talker

Posts: 3
Trades: 0
heh, I just joined yesterday, but I'm glad that you've found the correct solution ;-)
__________________

Please login or register to view this content. Registration is FREE
- IT Telework Network

Please login or register to view this content. Registration is FREE
- Teen Girls And Affiliate Programs
COLD_FIRE is offline
View Public Profile
 
Old 05-23-2009, 08:18 PM Re: Uploading images without reloading page
mdm
Junior Talker

Posts: 1
Name: marc
Trades: 0
hi guys,

just joined the site. i've just come across this requirement for a job and thought i'd add my bit. on another site i had successfully ran a php file externally using AJAX. The job of the php page was to send an email which is does. However when i tried the same method to upload a file it didn't work. I put this down to the fact that, on the email sending example it was merely getting the values of the form, whereas on the file upload attempt it didn't quite work. i had tested the upload php page with a standard form submit method and it worked fine, any clues on why?

when uploading a file with php and you have the attribute enctype="multipart/form-data" on a form, is the only way this extra data transferred by doing a standard sumbit? i'm thinking yep as on the php upload page we don't actually use $_REQUEST and use $_FILES instead?

From reading the thread i've cottoned onto the idea using a hidden iframe and will get back to you with my results.


thx for any thoughts or confirmations
mdm is offline
View Public Profile
 
Old 05-25-2009, 03:05 AM Re: Uploading images without reloading page
Novice Talker

Posts: 7
Trades: 0
I would recommend using a mix of PHP and AJAX in order to achieve this. Ajax is gaining popularity very fast. With that, you will be able to accomplish exactly what you are trying to do.
__________________
TeraDepot.com - File Hosting, Storage & Sharing
Register Today !!!

Please login or register to view this content. Registration is FREE
teradepot is offline
View Public Profile
 
Old 05-26-2009, 08:54 AM Re: Uploading images without reloading page
zanes's Avatar
Novice Talker

Posts: 5
Name: Why?
Trades: 0
Just because you can do something doesn't mean that you should.
It's good when a tab click takes effect immediately, changing the panel area without a full page reload. But... How many picture per page?
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
zanes is offline
View Public Profile
 
Closed Thread     « Reply to Uploading images without reloading page
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31866 seconds with 12 queries