doy51723 2018-10-22 09:12
浏览 367

multipart / form-data上传文件并将其保存在PHP中

I´am using a Angular frontend and PHP backend to try upload files and save them on an ftp-server.

To Upload the Files is this code used:

uploadFiles(file: File, uploadFolder: string): Observable<ApiResponseModel> {
const adress = environment.apiAdress.api + environment.apiAdress.fileUpload;
let header: HttpHeaders = this.getHeader();
header = header.set('Content-Type', 'multipart/form-data');

const formData: FormData = new FormData();
formData.append(uploadFolder, file, file.name);

return this.httpClient.post<ApiResponseModel>(adress, formData, {headers: header });
}

In my PHP backend i get the file Content und a description of the Post(Content-Type, Content-Disposition, etc), but i cant create a file as long as the additional information in the content is available. Is it possible to remove them easily?

The file-content i get looks like this:

"------WebKitFormBoundaryCr85Bf8XFGMEeJy5

Content-Disposition: form-data; name=""; filename="PDF_Test.pdf"

Content-Type: application/pdf

%PDF-1.5 %����

PDF Content

------WebKitFormBoundaryCr85Bf8XFGMEeJy5 "

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试