Spróbuj w ten sposób:
<form name="form" method="post" action="upload.php" enctype="multipart/form-data" >
<input type="file" name="my_file" /><br /><br />
<input type="submit" name="submit" value="Upload"/>
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_FILES['my_file']['name'])) {
$target_dir = 'Pliki/';
$temp_name = $_FILES['my_file']['tmp_name'];
$path_filename = $target_dir.$_FILES['my_file']['name'];
// Check if file already exists
if (file_exists($path_filename)) {
echo 'Sorry, file already exists.';
} else {
move_uploaded_file($temp_name,$path_filename);
echo 'Congratulations! File Uploaded Successfully.';
}
}
?>
zamiast <br> w kodzie
<style>
input {
display: block;
}
input[type="submit"] {
margin-top: 1em;
}
</style>
<form name="form" method="post" action="upload.php" enctype="multipart/form-data" >
<input type="file" name="my_file" />
<input type="submit" name="submit" value="Upload"/>
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_FILES['my_file']['name'])) {
$target_dir = 'Pliki/';
$temp_name = $_FILES['my_file']['tmp_name'];
$path_filename = $target_dir.$_FILES['my_file']['name'];
// Check if file already exists
if (file_exists($path_filename)) {
echo 'Sorry, file already exists.';
} else {
move_uploaded_file($temp_name,$path_filename);
echo 'Congratulations! File Uploaded Successfully.';
}
}
?>