Upload Photo .net c#
Upload Photo .net c#
hii I purchased the data table editor and i add the upload.js plug-in but i don't know how אם Implement server side plug-in upload please can someone help me with that?? i need to upload to image only to file system mot to db tnx you all....
client side js
{label: "Info:",name: "info", type: "upload", display: function ( val, row ) {
return val && row.image.webPath ?
'<img src="'+row.image.webPath+'"/>' :
'No image';
}}
server side not mvc
Field res;
res = new Field("info").Upload(new Upload(context.Request.PhysicalApplicationPath + @"uploads\__ID____EXTN__"));
context.Response.Clear();
context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(res));
This discussion has been closed.
Replies
Hi,
Thanks for your purchase. Just for reference, I've deleted your three other discussions on this topic - just one post is enough :-)
The method you have used:
Is basically correct - however, there is no
__ID__
since you are not storing information on the database. You could use__NAME__
instead. You obviously need to be careful with this since uploading files with the same name could cause an issue. This is one of the reasons why it is a good idea to store information about the file on a database.Allan
allan
thank ou for the fast replay
as you mentioned the issue about the same file name
i realy need to store the information about the file in the db
so how can i add the info about the file in the db (.net style not mvc) and return the info to the editor
tnx
Hi,
The documentation for that is available here. It is fairly generic C# code used there - not MVC specific (I primarily use WebAPI myself).
Allan
when i try to add this code i get 2 err
1) Not all code paths return a value in lambda expression of type
System.Func<System.Web.HttpPostedFile,dynamic,dynamic>
2) Cannot convert lambda expression to type 'string' because it is not a delegate type
i have the red err syntax in new Upload( (err is her)
how can i resolved this
tnx
Hi,
Apologies, that was an error in the documentation. The lambda should have
return id;
as it needs to return a value.Alternatively, just use:
Allan
hii allan
when i try to use this nothing append no row was insert and no err was receive.
its just set the parameter and that it
what do i do worng??
Do you have an
image
database table with columnsid
,fileName
andfileSize
?Allan
yes i have
So when the form is displayed and you click on the "upload" button - select a file to upload - then what happens? Nothing?
If you look in your browser's debugging tools under the "Network" panel you will see the Ajax request being made - what is the reply from the server? There should be JSON data there, although it is possible that there is an error message.
Thanks,
Allan
ok
when i upload the image the request go to the generic handler and ther is no err
i can see the request and all the details
after it i call to the function
and Nothing happend the is no call to commit the upload to the db
and the function end with no err
Hi,
I'm sorry for the trouble you are having with this! The above code needs
return id
to be inserted - did you try adding that in? It shouldn't compile with out it.I've just tried setting this up myself and discovered that in 1.4.2 the C# version needs a join table that references the uploaded files - it throws an SQL error if that condition is not met.
This is the code I used:
Very similar to your own, although I've customised the database fields for my use case and added the
LeftJoin
.The good news is that the Upload is fully integrated into Editor 1.5 (no need for the Javascript plug-in) and this issue is not present in 1.5 as I've redesigned the upload to be easier to use!
1.5 will be out either at the end of this week or the start of next :-)
Regards,
Allan
thank you for the replay
i will try the last solution you send me ,and if i will have any err
i will wait to the last version next week
thank you
hii allan
is there any way to upload a photo without using your .NET class??
because when i get to the server side i have a stored procedure that insert all the data all in one.. so is there any way to use you javascript client side and my stored procedure server side to upload an image??
tnx
Yes, but you would need to handle the request yourself. Unfortunately, at the moment the client / server documentation hasn't had the upload information added to it (its on my to do list!) but you could use the browser's network tools to look at the examples on the Editor site to review the parameters sent to the server. There are three:
action
which is ==upload
uploadField
- the field nameupload
- The fileAllan
action which is == upload
•- uploadField - the field name
•- upload - I don't get the filed name whay???
Do you mean "what" or "why"? I don't really understand myself I'm afraid. The field name is the
fields.name
value you assign to the upload field. So you know which field is uploading a file if you happen to have multiple upload options.Allan
sorry for the misunderstood....
what I meant is I don't get the file name when i'm in the Handler
so the upload field is empty
the rest of the fields are ok
action = upload
uploadField = field name
but upload is empty
I'm afraid I still don't quite understand. The file name is not submitted as part of the three parameters Editor sends, just the three I listed above. You should be able to read the file name from the meta data about the file, which will depend upon how your server-side environment handles uploaded files.
Allan