开发者

How to make a file-field automatically show the file-chooser just before the form is submitted?

I am developing one web application using CakePHP , I will be providing one button to user as "Upload ". Once user clicks on this button, I wanted to display dialogue box(browse file) so that user can choose file which would be located on his/her local machine.

Once successful uploading file I wanted to post file's data in one <textarea> which will be used for further data processing.

Below is cakephp code which I used earlier:

echo $form->create('MyFile', array('action' => 'getTranslation', 'type' => 'file'));
echo $form->file('File');
echo $form->submit('Upload');
echo $form->end();

Here, I was getting two button's 'Upload' and 'Browse'. I don’t want to use t开发者_运维知识库wo buttons over here. I want to use only one button i.e. 'Upload' which achieves selecting file as well as posting to some action.

Please provide me your suggestions.

Thanks

-Pravin


I guess You could do that with some jQuery, add an listener to the file field, and once it's filled, post the form.

I also found this: Uploadify. If you look at the second demo, you'll see something that fits your needs. Check it out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜