File tree Expand file tree Collapse file tree 1 file changed +20
-15
lines changed Expand file tree Collapse file tree 1 file changed +20
-15
lines changed Original file line number Diff line number Diff line change 224
224
false ,
225
225
'files '
226
226
);
227
- if ($ result ) {
228
- $ relativeUrl = str_replace (api_get_path (WEB_PATH ), '/ ' , $ result ['direct_url ' ]);
229
- $ data = [
230
- 'uploaded ' => 1 ,
231
- 'fileName ' => $ fileUpload ['name ' ],
232
- 'url ' => $ relativeUrl ,
233
- ];
227
+
228
+ if (!$ result ) {
229
+ exit ;
234
230
}
231
+
232
+ $ relativeUrl = str_replace (api_get_path (WEB_PATH ), '/ ' , $ result ['direct_url ' ]);
233
+ $ data = [
234
+ 'uploaded ' => 1 ,
235
+ 'fileName ' => $ fileUpload ['name ' ],
236
+ 'url ' => $ relativeUrl ,
237
+ ];
235
238
} else {
236
239
$ userId = api_get_user_id ();
237
240
$ syspath = UserManager::getUserPathById ($ userId , 'system ' ).'my_files ' ;
246
249
$ suffix = '_ ' .uniqid ();
247
250
$ fileUploadName = $ fileName .$ suffix .'. ' .$ extension ;
248
251
}
249
- if (move_uploaded_file ($ fileUpload ['tmp_name ' ], $ syspath .$ fileUploadName )) {
250
- $ url = $ webpath .$ fileUploadName ;
251
- $ relativeUrl = str_replace (api_get_path (WEB_PATH ), '/ ' , $ url );
252
- $ data = [
253
- 'uploaded ' => 1 ,
254
- 'fileName ' => $ fileUploadName ,
255
- 'url ' => $ relativeUrl ,
256
- ];
252
+ if (!move_uploaded_file ($ fileUpload ['tmp_name ' ], $ syspath . $ fileUploadName )) {
253
+ exit ;
257
254
}
255
+
256
+ $ url = $ webpath . $ fileUploadName ;
257
+ $ relativeUrl = str_replace (api_get_path (WEB_PATH ), '/ ' , $ url );
258
+ $ data = [
259
+ 'uploaded ' => 1 ,
260
+ 'fileName ' => $ fileUploadName ,
261
+ 'url ' => $ relativeUrl ,
262
+ ];
258
263
}
259
264
echo json_encode ($ data );
260
265
exit ;
You can’t perform that action at this time.
0 commit comments