Я пытаюсь загрузить видео с угловым и отправить его на внутренний сервер php.
Я использую angular 6, я использовал ng2-file-upload, он работает с изображениями, но когда я отправляю видео, я получаю «Нет свойств» на сервере.
компонент.html
<div class = "container">
<div class = "navbar navbar-default">
<div class = "navbar-header">
<a class = "navbar-brand" href>Add Video</a>
</div>
</div>
<div class = "row">
<div class = "col-md-3">
<h3>Select files</h3>
Single
<input type = "file" ng2FileSelect [uploader] = "uploader" />
</div>
<div class = "col-md-9" style = "margin-bottom: 40px">
<h3>Upload queue</h3>
<p>Queue length: {{ uploader?.queue?.length }}</p>
<table class = "table">
<thead>
<tr>
<th width = "50%">Name</th>
<th>Size</th>
<th>Progress</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr *ngFor = "let item of uploader.queue">
<td><strong>{{ item?.file?.name }}</strong></td>
<td *ngIf = "uploader.isHTML5" nowrap>{{ item?.file?.size/1024/1024 | number:'.2' }} MB</td>
<td *ngIf = "uploader.isHTML5">
<div class = "progress" style = "margin-bottom: 0;">
<div class = "progress-bar" role = "progressbar" [ngStyle] = "{ 'width': item.progress + '%' }"></div>
</div>
</td>
<td class = "text-center">
<span *ngIf = "item.isSuccess"><i class = "glyphicon glyphicon-ok"></i></span>
<span *ngIf = "item.isCancel"><i class = "glyphicon glyphicon-ban-circle"></i></span>
<span *ngIf = "item.isError"><i class = "glyphicon glyphicon-remove"></i></span>
</td>
<td nowrap>
<button type = "button" class = "btn btn-success btn-xs"
(click) = "item.upload()" [disabled] = "item.isReady || item.isUploading || item.isSuccess">
<span class = "glyphicon glyphicon-upload"></span> Upload
</button>
<button type = "button" class = "btn btn-warning btn-xs"
(click) = "item.cancel()" [disabled] = "!item.isUploading">
<span class = "glyphicon glyphicon-ban-circle"></span> Cancel
</button>
<button type = "button" class = "btn btn-danger btn-xs"
(click) = "item.remove()">
<span class = "glyphicon glyphicon-trash"></span> Remove
</button>
</td>
</tr>
</tbody>
</table>
<div>
<div>
Queue progress:
<div class = "progress" style = "">
<div class = "progress-bar" role = "progressbar" [ngStyle] = "{ 'width': uploader.progress + '%' }"></div>
</div>
</div>
</div>
</div>
</div>
</div>
компонент.ts
const URL = global.getBasePathV2() + 'user/upload-file';
public uploader:FileUploader = new FileUploader({url: URL, additionalParameter: {'accessToken': userData.accessToken}});
-- php api я сделал var_dump в файлы:
var_dump($_FILES);
die();
вывод для изображения
array(1) { ["file"]=> array(5) { ["name"]=> string(9) "alpha.jpg" ["type"]=> string(10) "image/jpeg" ["tmp_name"]=> string(14) "/tmp/phpM0SSFB" ["error"]=> int(0) ["size"]=> int(13560) } }
выход для видео
array(0) {}
No properties
Любое предложение, пожалуйста?
@JaydeepMor Спасибо за ответ, я попробовал это, добавив allowedMimeType: ['image/jpeg', 'image/png', 'video/mp4' ], все еще есть «Нет свойств».






Итак, спустя долгое время я наконец-то получил успешную загрузку :)
Проблема была в php сервере. Оказалось, что мой код работал нормально, но для небольших видео < 2M :/
Я изменил конфигурацию в php.ini вот так:
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_input_time 300
php_value max_execution_time 300
И теперь я могу выкладывать видео размером < 20M :)
Надеюсь, это поможет некоторым из вас.
Может Вот этот пригодится. Я думаю, вам нужно добавить
allowedMimeType.