File tree Expand file tree Collapse file tree 1 file changed +63
-0
lines changed
ej2-asp-core-mvc/uploader/EJ2_ASP.MVC Expand file tree Collapse file tree 1 file changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,69 @@ public void Save()
167
167
}
168
168
```
169
169
170
+ ### Server-side configuration for save action with returned response
171
+
172
+ Here’s how to handle the server-side action for saving the file in server with returned response.
173
+
174
+ ``` c#
175
+ [AcceptVerbs (" Post" )]
176
+ public ActionResult Save ()
177
+ {
178
+ // for JSON Data
179
+ try
180
+ {
181
+ // Process uploaded data
182
+ var responseData = new
183
+ {
184
+ Success = true ,
185
+ Message = " Files uploaded successfully" ,
186
+ // Additional data can be added here
187
+ };
188
+
189
+ return Json (responseData );
190
+ }
191
+ catch (Exception e )
192
+ {
193
+ var errorResponse = new
194
+ {
195
+ Success = false ,
196
+ Message = " File upload failed: " + e .Message
197
+ };
198
+
199
+ return Json (errorResponse );
200
+ }
201
+
202
+ // for String Data
203
+ try
204
+ {
205
+ // Process string data
206
+ var data = " success" ;
207
+ // Return the string data
208
+ return Content (data );
209
+ }
210
+ catch (Exception )
211
+ {
212
+ var data = " failed" ;
213
+ return Content (data );
214
+ }
215
+
216
+ // for File Data
217
+ try
218
+ {
219
+ // Example: Retrieve file path for stream.txt
220
+ var filePath = " /stream.txt" ; // Example file path
221
+
222
+ // Return the file
223
+ return File (filePath , " text/plain" );
224
+ }
225
+ catch (Exception e )
226
+ {
227
+ return Content (" Failed to retrieve file response: " + e .Message , " text/plain" );
228
+ }
229
+ }
230
+
231
+ ```
232
+
170
233
## Remove action
171
234
172
235
The remove action is optional. Specify the URL to handle remove process from server.
You can’t perform that action at this time.
0 commit comments