该文件超过了Laravel中的upload_max_filesize ini指令(限制为2048 KiB)

时间:2017-09-21 21:31:55

标签: php laravel-5.4

当我尝试上传图片时,我在开发环境中遇到上述错误。我在这里做了以下

的其他答案
  • 设置upload_max_filesize和post_max_size
  • 重启wamp服务器
  • 关闭系统并重新启动系统

但我仍然无法克服错误。我做错了吗?以下是我的php.ini文件中的相关部分

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 100M

; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20

; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size = 125M

4 个答案:

答案 0 :(得分:5)

如果您使用的是LAMP(Apache服务器),则需要同时编辑 deleteFavorite(item: ItemSliding, id: number) { console.log('delete', id); let alert = this.alertCtrl.create({ message: 'Do you want to delete this favorite cabin?', buttons: [ { text: 'Cancel', role: 'cancel', handler: () => { console.log('Delete cancelled') } }, { text: 'Delete', handler: () => { let loading = this.loadCtrl.create({ }); let toast = this.toastCtrl.create({ message: 'Cabin ' + id + ' deleted successfully', duration: 3000 }); loading.present(); /*first error*/ this.favservice.deleteFavorite(id) .subscribe(favs => { this.favorites = favs; loading.dismiss(); /* second error*/ toast.present(); /* third error*/ } , errMsg => { this.errMsg = errMsg; loading.dismiss(); /* fourth error*/ }); } } ] }).then(alert => alert.present()); item.close(); } [ng] ERROR in src/app/pages/favorites/favorites.page.ts(57,21): error TS2570: Property 'present' does not exist on type 'Promise<HTMLIonLoadingElement>'. Did you forget to use 'await'? [ng] src/app/pages/favorites/favorites.page.ts(62,24): error TS2570: Property 'dismiss' does not exist on type 'Promise<HTMLIonLoadingElement>'. Did you forget to use 'await'? [ng] src/app/pages/favorites/favorites.page.ts(63,22): error TS2570: Property 'present' does not exist on type 'Promise<HTMLIonToastElement>'. Did you forget to use 'await'? [ng] src/app/pages/favorites/favorites.page.ts(66,24): error TS2570: Property 'dismiss' does not exist on type 'Promise<HTMLIonLoadingElement>'. Did you forget to use 'await'?

要修改为所需值(例如10 MB)的属性:

  1. upload_max_filesize:默认值为2M(兆字节) /etc/php/7.2/cli/php.ini
  2. post_max_size:默认为8M(兆字节) /etc/php/7.2/apache2/php.ini

保存 ; Maximum allowed size for uploaded files. ; http://php.net/upload-max-filesize upload_max_filesize = 10M 文件后,运行: ; Maximum size of POST data that PHP will accept. ; Its value may be 0 to disable the limit. It is ignored if POST data reading ; is disabled through enable_post_data_reading. ; http://php.net/post-max-size post_max_size = 10M

注意:在编辑php.ini值之前,请确保sudo service apache2 restart是已加载的php配置文件。该命令为:php.ini

答案 1 :(得分:2)

终于找到了wamp的解决方案,点击wamp图标 - &gt; PHP - &gt; PHP设置并设置upload_max_filesize和post_max_size。这将自动设置由apache加载的实际php.ini中的值。然后重启wamp服务。我希望这有助于某人节省我花在试图解决这个问题的时间。

答案 2 :(得分:1)

我同意你的看法。我正在使用Laravel开发一个项目,我使用的PHP版本是7.2,但是从WAMP服务器进行更改时更改的upload_max_filesize = 100M行是PHP 5的php.ini文件。

我在项目中创建了一个空白页,并使用phpinfo()命令找到了php.ini文件所在的位置。

我中的文件路径:C:\wamp64\bin\php\php7.2.4\php.ini

当我看到upload_max_filesize行是2M时,我感到震惊。进行更改后,我重新启动了服务,感到很开心!

答案 3 :(得分:-1)

您是否正在更改正确的php.ini文件?那些WAMP装置可能很棘手 您可以使用phpinfo()函数查看正确的路径。

重复: Small file get uploaded but not large file in Laravel