I have this code
<?php // display file upload form
if (!isset($_POST['submit'])) { ?>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="8000000" /> Select file:
<input type="file" name="data" />
<input type="submit" name="submit" value="Upload File" /></form>
<?php
} else {
// check uploaded file size
if ($_FILES['data']['size'] == 0) {
die("ERROR: Zero byte file upload");
} // check if this is a valid upload
if (!is_uploaded_file($_FILES['data']['tmp_name'])) {
die("ERROR: Not a valid file upload"); } // set the name of the target directory
$uploadDir = "./uploads/"; // copy the uploaded file to the directory
move_uploaded_file($_FILES['data']['tmp_name'], $uploadDir . $_FILES['data']['name']) or die("Cannot copy uploaded file"); // display success message
echo '<p style="text-align: center">
Soubor byl úspěšně nahrán na server. <br>
<a href="index.php" class="button1">Zpět</a>
</p>
' ; } ?>
And I have a problem - it works, uploads the file to server but if there is a break in the file name, I cannot download it. e.g I want to upload "my salary únor.pdf", but the server keeps looking for file "my". Is there a way to modify this code to change the breaks in the file name to "_"? Also I would like the server to be in utf-8 letter (as the server changes the file name to silly names e.g. u?nor) So if there is a option for that too that would be great. (or just let php change the file name inty "my_salary_unor" Thank you all for your help ad sugestions.