1

I have a shell account and I created there a file uploader. It has two files. upload.html

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Send</title>
</head>

<body>
    <form enctype="multipart/form-data" action="upload.php" method="POST">
        <input name="thefile" type="file" /><br>
        <input type="submit" value="Send" />
    </form>
</body>
</html>

and upload.php

<?php
header('Content-Type: text/html; charset=utf-8');

$thefile_tmp = $_FILES['thefile']['tmp_name'];
$thefile_name = $_FILES['thefile']['name'];

if(is_uploaded_file($thefile_tmp)) {
    move_uploaded_file($thefile_tmp, "files/$thefile_name");
}
?>

Everything works fine, but I want to be able to play with uploader on my computer (windows 7). So I installed Apache24 and php7 as is this tutorial. I noticed however, that when I upload file with polish characters (and i need them) it changes them to some strange symbols. I found a solutin here. Namely I changed upload.php to

<?php
header('Content-Type: text/html; charset=utf-8');

$thefile_tmp = $_FILES['thefile']['tmp_name'];
$thefilename = $_FILES['thefile']['name'];
$thefile_name = iconv("utf-8", "ISO-8859-2", $thefilename);

if(is_uploaded_file($thefile_tmp)) {
    move_uploaded_file($thefile_tmp, "files/$thefile_name");
}
?>

Everything works fine on my compluter. However when I put such upload.php on my shell account, it changes polish characters to strange symbols.

I deduced that this mismatch is due to servers' php configurations.

So I want to change configuration on my computer, so that first version of upload.php would work.

I looked into phpinfo() in my shell account and I tried to set similar setting on my computer phpinfo().

I tried to change default_charset in core but it didn't help.

I also tried to change iconv.input_encoding,iconv.internal_encoding, and iconv.output_encoding. None of this helped neither.

There are so many options that I am lost.


Version info

My shell account:

  • PHP Version 5.4.45-0+deb7u2
  • SERVER_SOFTWARE Apache/2.2.22 (Debian)

My computer:

  • PHP Version 7.0.5RC1
  • SERVER_SOFTWARE Apache/2.4.18 (Win64) PHP/7.0.5RC1
Community
  • 1
  • 1
Fallen Apart
  • 723
  • 8
  • 20
  • The problem is on the Windows end. It's not recommended to do PHP development on one operating system when you are deploying to a different operating system. – Michael Hampton Mar 28 '16 at 00:47
  • @MichaelHampton So it would be recommended to install Debian and later Apache as well as PHP on that beast. Before I do so I would like to ask, if there are any things I should be careful about? – Fallen Apart Mar 28 '16 at 02:49

0 Answers0