How to edit htacess file to support file upload - php

I have a sample image upload code written in php. An ios developer calls the web service. The file upload works well with One server but fails to upload in another server.
Checked the permissions, directory listing etc. Of all the above when trying to upload an image, Server throws 500 internal error.
I think there might be an issue with .htaccess
Can anyone guide me to edit the htaccess so that it supports image upload.
Thank you.
While uploading via browser, the file upload works fine. It is not returning any errors
here is the error log
PHP Warning: fopen(xml/) [function.fopen]: failed to open stream: No such file or directory in /home/appsimon/public_html/api/import.php on line 271
Actually it worked on this server till last week. All of a sudden file upload failed
code in htaccess
#old php Handler
#deny from all
#allow from ip address
Only these 3 commented lines
Error from the app console
<Warning>: aResponse:<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
webmaster#appsimon.com and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
<p>Additionally, a 500 Internal Server Error
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>
Feb 6 00:30:48 Varmas-iPhone SNMC[1944] <Warning>: -JSONValue failed. Error trace is: (
"Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Unrecognised leading character\" UserInfo=0x541a40 {NSLocalizedDescription=Unrecognised leading character}"
)
Feb 6 00:30:49 Varmas-iPhone SNMC[1944] <Warning>: fail

in your htaccess try adding these values and see what happens
php_value upload_max_filesize 100M
php_value post_max_size 100M
php_value max_execution_time 180
php_value max_input_time 180
adjust the values as needed

Related

Reasons of 500 internal server error in php

I am trying to upload the large image(1 MB) files on server using php code but it is
showing the 500 internal server error it is only uploading up to 128 KB.
Even though i have checked all the required setting of my server
all settings are correct i am not getting how to trace this error.Is
there any other setting which i don't know so please help me to find out or
if all settings is fine then please help me trace out this 500 internal server error.
Settings which i have already verified.
memory_limit 90M
post_max_size 64M
upload_max_filesize 64M
FcgidMaxRequestLen 104857600
Below is the error:
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster#domain.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Use two lines at the top of the page to display errors
ini_set("display_errors", "1");
error_reporting(E_ALL);

Uploading large file (45MB) via AJAX failing

I'm trying to upload files via AJAX. Small files ~10MB are being uploaded successfully.
However, when I try to upload larger files, it fails with the following message:
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, webmaster#.com and inform
them of the time the error occurred, and anything you might have done
that may have caused the error.
More information about this error may be available in the server error
log.
Additionally, a 500 Internal Server Error error was encountered while
trying to use an ErrorDocument to handle the request.
I'm using Laravel 5 on dreamhost.
I've put debugging messages everywhere, but it seems that my PHP code is not being executed at all. Also, there's no info in error.log either.
I've checked php.ini with following settings:
max_execution_time 30
max_file_uploads 20
post_max_size 500M
upload_max_filesize 500M
Intially, I had mounted /tmp folder at one place which had partition size of 100MB. At that time, the error.log said "modsecurity: input filter failed writing 8192 bytes to temporary file"
So I changed to location of /tmp folder to my home folder in order to remove size restrictions, but not working.
Here is the current behaviour:
File upload shows 100%.
Then the request waits for sometime without causing logs.
After a while, the above mentioned error message is returned.
Let me know which further info is required.
Thank you very much!
For such issues, You should play with few parameters of php.ini.
max_execution_time
max_input_time
post_max_size
upload_max_filesize
Try to keep max_execution_time and max_input_time to ZERO (0).
It won't bound your execution to 30 seconds.
Hope this helps!!

500 Internal Server Error Laravel

Sometimes i got this error: 500 Internal Server Error
My PHP Version 5.4.4-14+deb7u14
My Laravel Version "laravel/framework": "4.2.*"
Apache Server
My DocumentRoot & Directory in httpd.conf is set to: /usr/local/sites/mysite-laravel/public
My server logs:
(104)Connection reset by peer: mod_fcgid: ap_pass_brigade failed in handle_request_ipc function
[Mon Sep 01 14:52:33 2014] [error] mod_fcgid: process /var/www-data/fcgi-bin/php5-fcgi(25404) exit(communication error), get unexpected signal 11
Does anyone know about this? or is this is what happens in Laravel 4?
Make sure your folders have 755 permission. I cleared this issue with permission. This is first thing do any others. You can get successful output.
Thanks
If you are using a .htaccess on your site, it may be interfering with the web page you are trying to load into your browser. Please double check the .htaccess configuration. Any syntax errors will cause a 500 Internal Server Error message to be displayed instead of your website.
To confirm whether a misconfiguration .htaccess is the cause of the 500 Internal Server error, either remove or rename the .htaccess file temporarily and then try to reload the page
PHP Coding Timing Out
if your PHP script makes external network connections, the connections may time out. If too many connections are attempted and time out, this will cause a "500 Internal Server Error." To prevent these time outs and errors, you'll want to make sure that PHP scripts be coded with some timeout rules. Typically, however, catching a timeout error when connecting to a database or externally to remote resources (example: RSS feeds) are difficult. They, in effect, freeze the script from continuing to run.
Removing any external connections can increase both the performance of your website and decrease the chances of you receiving a "500 Internal Server Error."
This problem happen when the connection between client and server disconnected before complete the request.
I Solved this problem by increase the values of FastCGI configurations which located in file "/etc/httpd/conf.d/fcgid.conf" (In Apache 2.4, CentOS 7) to this values:
<IfModule mod_fcgid.c>
FcgidMaxRequestLen 10737418240
FcgidIOTimeout 36000
FcgidConnectTimeout 36000
FcgidBusyTimeout 36000
FcgidIdleTimeout 96000
FcgidProcessLifeTime 96000
</IfModule>

Internal Server Error - PHP - cPanel

I have a PHP site hosted with cPanel.
Yesterday, I changed certain directory listings (using Index Manager). I initially changed the settings from "Default System Setting" to "No Indexing" on all the directories and afterwards I have started getting following error :
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster#***.*** and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
I have then reverted all the settings back to their original but still getting the same error.
Following error is shown in Error Log -
[Tue Dec 04 01:20:54 2012] [alert] [client 119.226.234.18] /home/***/public_html/.htaccess: ErrorDocument takes two arguments, ErrorDocument Apache configuration directive
I don't understand how to resolve this!! Please help!!
It's an error in your htaccess.
Open .htaccess in a texteditor. The line with ErrorDocument should look like this:
ErrorDocument 404 /404.html
I was also facing same issue.
By changing the folder permission that I was trying to access to 755 in file manager resolved the issue.
Try to check this error log:
/usr/local/apache/logs/error_log

session didn't started

I've found an amazing problem. I today released a website which is based on MLM business. The whole day I test the website, but no errors found. But at night when I tried to login a member page I'm getting the below error:
[21-Sep-2011 13:30:36] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: open(/tmp/sess_44507540b8d51d06160a2856360692e6, O_RDWR) failed: Permission denied (13) in /home/dashingb/public_html/sts/conf.php on line 3
I'm on shared host with apache server. I've no root access. How to solve the problem ? also above is showing WARNING, But when I try to open the login page it shows 500 error (http://dashingbird.com/sts/admin/)
my session starting method is as below:
<?php
if(! isset($_SESSION)){
session_start();
}
?>
Plus below error is getting:
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, webmaster#dashingbird.com and
inform them of the time the error occurred, and anything you might
have done that may have caused the error.
More information about this error may be available in the server error
log.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request. Apache/2.0.63 (Unix)
mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1
mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at dashingbird.com Port
80
When I turned error_reporting(E_ALL), I just got the above warning (session warning).
please help me..
Most likely PHP can't write out the session file to whatever directory is specified for the session save path. You can find out what that path is with session_save_path().
If you can't modify the permissions on that directory to allow writes by the webserver, you'll have to change the PHP configuration to point at a directory where it CAN read/write files. Or manually override it in each script with a session_save_path('/path/to/writeable/dir') before you call session_start().
It seems there is something wrong on the server. Generally on a shared host there is not musc you can do yourself. I would suggest emailing (or opening a ticket) your hosting support.
Its most likely some sort of permission issue.
Also the 500 error means something is wrong with server config, Mostly it is caused by some error in .htaccess file.

Categories