[error] can't upload image with HTTPS

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
Kate Hayashi
Posts: 2
Joined: Tue May 03, 2016 3:29 pm

[error] can't upload image with HTTPS

Post by Kate Hayashi » Tue May 03, 2016 4:41 pm

Hi everyone

Since I changed protocol from http to https some days ago, can't upload image. To solve the problem, I searched on the internet many times, but couldn't get an available answer at all. So post here.
Of course, when I have used http, any images could have been uploaded.

s9s says on admin panel>addmedia>brose.. and clicked [go] button.
" Unknown error occurred, file not uploaded. Maybe your filesize is larger than the maximum size allowed by your server installation. Check with your ISP or edit your php.ini file to allow larger file size uploads."

my environment:
Server: ubuntu 14.04.1
Apache 2.4.18
MySQL 5.6.30
PHP 5.6.20-1
php.ini :
file_uploads = On
;upload_tmp_dir = (commented out) probably used /var/tmp?
upload_max_filesize = 16M
max_file_uploads = 20
URL in s9y Configulation>Path>URL to blog ---> https://www.mydomain.org/news/

/news/ means s9y installed directory
Apache access log:
my.isp.jp - - [03/May/2016:23:03:32 +0900] "POST /news/serendipity_admin.php?serendipity[adminModule]=media&serendipity[sortorder][perpage]=8&serendipity[sortorder][order]=i.date&serendipity[sortorder][ordermode]=DESC& HTTP/1.1" 500 7597 "https://www.mydomain.org/news/serendipi ... =addSelect" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0"

Apache error.log:
[Tue May 03 23:11:07.687291 2016] [:error] [pid 2669] [client my.ip.addr.ess:55143] PHP Warning: Unknown: open_basedir restriction in effect. File(/tmp) is not within the allowed path(s): (/var/www/html/) in Unknown on line 0, refererer: https://www.mydomain.org/news/serendipi ... =addSelect

[Tue May 03 23:11:07.690349 2016] [:error] [pid 2669] [client my.ip.addr.ess:55143] PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0, referer: https://www.mydomain.org/news/serendipi ... =addSelect

Directory permissions:
/news/uploads/ --> 777 owner me : group me
/var/tmp/ --> 777 owner root : group root

Surely this is Internal Server Error, but I don't know where I should tweak to solve this problem.
Any suggestions welcome
Thanks

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: [error] can't upload image with HTTPS

Post by Timbalu » Tue May 03, 2016 5:23 pm

Well, it clearly says: "open_basedir restriction in effect. File(/tmp) is not within the allowed path(s)" and further on in process: "PHP Warning: File upload error - unable to create a temporary file", which is, since PHP couldn't get the file from your Servers tmp dir.

So you either allow "/tmp" within the include_path php.ini directive and restart Apache, or you add your own domain web phptmp upload directory, and enable it like such:

Code: Select all

<IfModule mod_ssl.c>
  <VirtualHost *:443>
    DocumentRoot /var/www/html
    ServerName example.org
    ServerAlias  www.example.org example.org
    php_admin_value open_basedir /var/www
    php_admin_value upload_tmp_dir /var/www/phptmp/
    php_admin_flag safe_mode Off

    <Directory "/var/www/html">
        ....
    </Directory>
    ....
  </VirtualHost>
</IfModule>
and make /var/www/phptmp/ writeable and restart apache.
The Serendipity "uploads" directory is the dir where the file actually lives after all execution and image manipulation in the upload process has been done already.

PS: You could also try with

Code: Select all

php_admin_value open_basedir "/var/www/phptmp/:/tmp/"
which should allow both.

(Or you enable the php.ini

Code: Select all

upload_tmp_dir = "/var/tmp/"
which could/should(?) do if that directory exists.)
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

Kate Hayashi
Posts: 2
Joined: Tue May 03, 2016 3:29 pm

Re: [error] can't upload image with HTTPS

Post by Kate Hayashi » Wed May 04, 2016 3:34 pm

Hi Timbalu and everyone

Good news, Timbalu! I made re-configuration in accordance with your suggestions, easily the problem solved *^^*

I didn't know it needed to specify special description in 000-default.conf in ubuntu (similar to httpd.conf).

Code: Select all

    php_admin_value open_basedir /var/www
    php_admin_value upload_tmp_dir /var/www/phptmp/
    php_admin_flag safe_mode Off
I only added the lines above.

Thanks a lot, Timbalu <3
ciao!

Post Reply