Upload file from GWT to php Server - php

I want to upload a file from a GWT form panel to php server;
FormPanel formPanel = new FormPanel();
formPanel.setAction("http://www.digicom.vacau.com/FileUpload.php");
formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
formPanel.setMethod(FormPanel.METHOD_POST);
In the form panel, I'm placing a file upload widget and submit button. But it is not uploading. Can someone help??

You still need to attach a (absolute or vertical)panel to the formPanel and attach a FileUpload widget to that. Don't forget to use formPanel.setWidget(Panel panel)!
Take a look at this code:
http://google-web-toolkit.googlecode.com/svn/javadoc/1.6/com/google/gwt/user/client/ui/FormPanel.html

Related

Upload Like Normal using the jQuery-File-Upload plugin

I am wanting to use the jQuery-File-Upload plugin located here https://github.com/blueimp/jQuery-File-Upload . I have implemented it for the most part but I am having trouble actually submitting the form. What I would like to do is when the user clicks on "Upload", instead of uploading it to a default directory on my server, I would like the page to POST so I can verify the files and then store them on my server. Is this possible to do with this plugin?
According to https://github.com/blueimp/jQuery-File-Upload/wiki/API it looks like you should be able to set an upload handler end point using a url parameter during initialization. I would image you could point that to a php/aspx/anything else location and handle it in there.
The File Upload widget is initialized by calling the fileupload method
on a jQuery collection with the target HTML element:
$('#fileupload').fileupload();
The target element is usually a container element holding the file
upload form, or the file upload form itself, but it can also be just
the file input element itself, if an url is provided as options
parameter.
The initialization method's first argument is an object that allows
you to initialize the widget with various Options:
$('#fileupload').fileupload({
url: '/path/to/upload/handler.json',
sequentialUploads: true
});

Upload an image with PHP using JQUERY Object

I have an image (a captcha specifically) that I want to upload to my server using PHP (or if possible and better, only JQUERY)
I created an object with this code:
var newIMG = $("img[name='captchaImage']").clone();
But I cannot send it via jQuery's ajax method or else. (Even tried to manually add but no idea how to send an object as file)
What should be the simplest PHP / jQuery code to send this object?
Thanks in advance,
You can use jsupload plugin for this purpose.
One cannot upload files using AJAX..
You can also use an iframe to simulate uploading the files..
only jquery file upload is not possible you need php
and you can use the jQuery File Upload to upload file via ajax and jquery

how to upload file php through jquery and smarty

i need to upload a file doc or pdf or rich text through jquery and smarty
i try to pass the file in jquery is given below
window.location.href= sitePath+'download?p='+$('#file').val();
but the p doesn't have value. how to get the file path or name and how can stored in server
in controller i write just pass the query to model is given below
$model=new download();
$id=$model->upload($param);
and i can't develop the model code....
please help me
You can't send files like that.
You should either submit a form with enctype="multipart/form-data" or use some AJAX uploader (which uses form submit to iframe and then stores a file using PHP script).
EDIT: Some references
http://www.w3schools.com/php/php_file_upload.asp - tutorial on how to upload a file using PHP
http://valums.com/ajax-upload/ - example of ajax uploader.
EDIT2: The problem is not with your model code but with the way you try to submit a file.

save a file generated by a php script in to a directory by save dialog form

I have a php script that generate a pdf file.
So I have an html page with jquery javascript that do an ajax call at this php script and retrieve the pdf file content.
I would that this file will be saved in a location choosed by a save file dialog.
How can I do it?
Thank you so much.
You don't need Ajax - just do a
location.href = "fileURL.php";
(or alternatively, have the user click on a link) and if the headers are set correctly, a download dialog will present itself.

jQuery post upload file

I have a image upload form which adds an image to my server, although I'm wanting to load the information through jQuery ajax so the form doesn't refresh on submit.
At the moment I have
$('.img-form').submit(function(e) {
e.preventDefault();
$.post(document.href, $(".img-form").serialize());
});
Which seems to post the document, although i need to get it to call my ImageUpload() function from the PHP once I've pressed the submit.
My php function is called something like this,
<?php $Users->TutorialImageUpload(); ?>
If I understood correctly, you wish to upload an image without refreshing the page, and call your imageUpload() function.
As mentioned in the comments, you cannot upload in such a manner, however, what you could do
is put your upload form and code in a seperate php file and include it in the page as an iframe. This would upload your files withough refreshing the page.

Categories