i'm new to the kendo ui
and i tried the sample of Kendo UI Uploader
and i need to save the data to the sql server database with WCF service via Kendo Upload in Jquery
i have the following doubts
1) in Asynchronous mode
async: {
saveUrl: "saveHandler.php",-------------------- ->> here what happens in this php file
removeUrl: "removeHandler.php",------------------>>here what happens in this php file
removeField: "fileNames[]"
}
2) if i need to save the data in local drive then what can i do for that?????
3) i want the original Path of the file which i had selected via kendo Uploader
please clarify me the above issues one by one
thanks & regards
-santhosh
5 Answers, 1 is accepted
As far as I'm aware WCF services allow (raw) file uploads, but does not provide any built-in support for multi-part requests. See this forum thread for details.
The gist is that if you can make your service to accept regular form submits then it will work just fine with the Kendo UI Upload.
As for 2) and 3) - the file will be accessible in the WCF service and can be saved at an appropriate location.
The original file path is not available. The browsers remove it from the file name for security reasons.
T. Tsonev
Telerik
could you please give me the sample Worked Example for the WCF service along with Kendo uploader for async mode
and i'd worked another example
this is my fileupload.aspx file
$(document).ready(function ()
{
$("#fileuploder").kendoUpload({
localization: {
"select": "Attach"
},
async: {
saveUrl: "kendouploder.aspx",
autoUpload: true
},
error: function (e) {
alert(e);
}
});
});
public partial class kendouploder : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ProcessRequest();
}
public object ProcessRequest()
{
HttpFileCollection fileCollection = Request.Files;
for (int i = 0; i < fileCollection.Count; i++)
{
HttpPostedFile filePath = fileCollection[i];
string savepath = "D:/";
string filename = filePath.FileName;
if (!Directory.Exists(savepath))
Directory.CreateDirectory(savepath);
filePath.SaveAs(savepath + filename);
Response.ContentType = "application/json";
return "";
}
return "";
}
}
}
could you please tell me what is the exact problem over the above example and correct it
i'd attached the image which shows error but the attached file saves successfully
The code sample doesn't use WCF, but I can spot the problem nonetheless. The response content type is set, but there's no actual response sent.
Please, try the following:
public override void ProcessRequest(HttpContext context) {
// ...
context.Response.ContentType = "text/plain";
context.Response.Write("");
}
The ProcessRequest method is void and shouldn't have a return value.
Sample code for parsing form posts in WCF service is available in this question on SO.
T. Tsonev
Telerik
i'd used the below code as you suggested
{
context.Response.Expires = -1;
if (context.Request.Files.Count > 0)
{
HttpFileCollection fileCollection = context.Request.Files;
if (fileCollection.Count > 0)
{
HttpPostedFile filePath = fileCollection[0];
string savepath = "D:/";
string filename = filePath.FileName;
if (!Directory.Exists(savepath))
Directory.CreateDirectory(savepath);
filePath.SaveAs(savepath + filename);
}
}
context.Response.ContentType = "text/plain";
context.Response.Write("");
}
which it is shown in image
please clarify me where i'd done the mistake
I guess we should terminate the request to prevent the default ASP.NET rendering from overriding our output:
context.Response.Write("");
context.ApplicationInstance.CompleteRequest();
Regards,
T. Tsonev
Telerik