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.
Related
I am trying to upload my new website (codeigniter project) to the server. .htaccess file is used in my project and it is working properly in localhost. Also, i can upload the file too, but after uploading, it is not working. I always need to add the 'index.php' in url. I can't see the .htaccess file and when i trying to upload it again, it is showing the message, the file is alredy exist. Do anyone know the reason?
Try using FileZilla and enable hidden files to be visible:
Open FileZilla FTP client.
From the Menu bar choose Server
Select Force Showing Hidden Files which should be the last option.
One other thing to check is if you're using Apache or Nginx because Nginx does not support the .htaccess file
I am using winSCP(FTP software) to upload my .htaccess. As you mentioned you are not able to view it. However when you try to create a new file through winScp, the file will be automatically loaded to your text editor.
I am not sure if other FTP software works the same.
The file exists, but is hidden.
Probably the user on whose log does not have permission to replace him.
remove .htaccess file from your server , but before make sure that that file is no more useful for you .
other way
open the hosting server .htaccess file in online editor of cpanel
now copy past your htaccess file codes which required to be change.
As mentioned in the comments, it could be that the server is running for example Nginx instead of Apache.
However, I think the most likely cause for the .htaccess file not having an effect is a configuration issue. It could be that .htaccess functionality is disabled either in config you can manage, or in the server's config.
Contact your webhost to resolve this issue.
I am moving an existing word press site to azure, I am trying to use Tools => Import, I installed the "Import WordPress" plugin, but after upload the XML it takes some minutes and shows me a blank page, then I notice that no posts, comments, pages, etc. were imported.
When you import your .XML file, you have the message with a succefully importing? Or some wrong message?
Normally this kind of situations with WordPress migrations it was about memory limit, you can change it in your wp-settings.php
If you have 32 M change it for 128M and try again.
'WP_MEMORY_LIMIT', '128M'
If you are in a shared-hosted you need to talk with your provider, if not be sure that you have memory to upload big files.
I exported the all content of my WordPress on local and imported to Azure platform, but I still couldn’t reproduce your issue. May you supply the XML snippets for further discussing?
In order to find the cause of the problem, you need to turn on the display_errors setting on to check if there were any PHP error, to configure PHP setting on Azure, you can follow the steps:
1, Add a .user.ini file to your root directory.
2, Add configuration settings to the .user.ini file using the same syntax you would use in a php.ini file. With your demand, your .user.ini file would contain this text:
display_errors = On
; Maximum size of POST data that PHP will accept, If needed.
post_max_size = 20M
3, Deploy your web app.
4, Restart the web app.
Also, we can use FTP tool or WebMatrix to connect your Azure Web sites server to create and modify the custom configuration file.
Another approach about migrated an existing application to Azure Web Apps is that we can use FTP Tool or Git to upload the whole application folder to the root directory on Azure.
You can see step by step reference on this thread.
The default root directory is D:\home\site\wwwroot.
Is there a way, through php.ini or .htaccess to disable all file uploads to a server?
The only catch is, I want to have one folder (example an admin folder) to still have access to upload.
I am thinking along the lines of when you disable eval and exec.
This question stems from the fact that I have seen sites infected with malware, which are located in all random spots through the server - a recent example I have seen is something similar to:
eval(gzinflate(base64_decode("HZ3fdsfHjtfvdqlkdsfabf5Y7OAQfMCRc9YKaYc5o0mHOmmJ6+ .... ));
Located in a file called stp.php on a server. My thinking is that if the sites users need no access to upload files (which they don't), then it should be simply disabled.
Yes. In your php.ini file set file_uploads=Off as described here.
This will disable all file uploads through HTTP.
I've been playing about with this plugin over the last few days, customising it and setting it up to work exactly as my site requires. I got it all working fine on my localhost server, with no errors/bugs. However, when I try to upload it to my Plesk server, no files are shown onload (even though there are images in the target folder), and when I try to upload im presented with the " Empty file upload result" error. Oddly.. the file upload seems to work even though its displaying the error, and the relevant images appear in the folder. So it seems to only he having a problem with reading, but not with writing?
I've checked the permissions of the files and thumbnails folder, and set them both to 777, so that cant be the issue.
I really cant see why this is working on my localhost server but not my Plesk server. Any help would be much appreciated.
Finally solved this issue. The problem was that my Plesk server was running a very old version of PHP. Updating it to 5.3 seems to have cleared up my issues.
I have a php script which uploads images to a temporary folder on the server.
This works on my local computer with the local (virtual) server. (wampserver).
However, on the production server (linux) I cant get it working.
Everything is loading as it should, except for that the file doesn't show up on the server.
My Q is, is there anything I should think about when moving to a production server with uploading images or files?
I have set permissions on the folder where the images are supposed to go to 777 and also the php-code which uploads them to 777.
Thanks
is there anything I should think about
when moving to a production server
with uploading images or files?
Yes.
Error handling.
You have to keep in touch with PHP error reporting in general
and properly handle $_FILES['name']['error'] variable in case of upload.
These two sources will provide you with sufficient and precise information on any error occurred.
I highly recommend to you first to read this article before setting 777 permission on the server. Besides, there are different ways of uploading files are shown, so I think you will solve your problems after reading this article. Good luck
I know this question is old but I doubt any of the answers given are correct as I have had this exact problem and it turned out to be that when I created the php form I forgot to add this line to the form tag enctype="multipart/form-data" so processing the form on my local machine worked fine but when I tried to upload an image to the production server with the form it wouldn't process the image file, it would process all the other data from the form just not the file that needed to be uploaded. After I added the line above it worked fine.