简体   繁体   中英

PHP File Upload No Longer Working, No Changes Made (Plesk Hosting)

I have a web app built with angular and PHP that has been established and running since 2016. There is a file upload feature that will upload a file from client-side app to a directory on the server. I noticed the upload is no longer working. Nothing has changed on our end with the configuration of server/hosting or front-end application. The directory still exists and can successfully list files from the front. I get an internal server error when trying to upload with the code below. Very simple example and nothing to indicate this code no longer works. I have file-uploads = on in the php.ini file. It is hosted on GoDaddy. I have checked the error logs and can see that the request is failing but with no detail. Is anyone aware of what may be causing this? I can provide more detail, if thought necessary.

<?php
  $target = '../images/attorney_photos/'.$_FILES['file']['name'];
  move_uploaded_file($_FILES['file']['tmp_name'], $target);
  print('/assets/images/attorney_photos/'.$_FILES['file']['name']);
?>

If your file upload is on then check for

upload_max_filesize

and

post_max_size

in your php.ini file and also if you want to upload more than a specific limit each request, then check

max_file_uploads

to be more than files you want upload.

Also it's better to use a tested library for upload your files. you can search for codeguy/upload in packagist and install it with composer for advanced usage or if you no need lots of options you can download this file from github that is so simple, easy to use and well written.

I hope this helps:)

login to plesk administrator panel then goto Domain->Website->PHP Settings

Change upload_max_filesize from "2MB" to "16MB"

Save and try uploading again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM