I create a field for uploading files, here is a page for downloading images:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Π’Π΅Π³ INPUT, Π°ΡΡΠΈΠ±ΡΡ accept</title> </head> <body> <form action="handler.php"> <p><strong>Π£ΠΊΠ°ΠΆΠΈΡΠ΅ ΠΊΠ°ΡΡΠΈΠ½ΠΊΡ Π² ΡΠΎΡΠΌΠ°ΡΠ΅ JPEG, PNG ΠΈΠ»ΠΈ GIF</strong></p> <p><input type="file" name="img" accept="image/jpeg,image/png,image/gif"> <input type="submit" value="ΠΡΠΏΡΠ°Π²ΠΈΡΡ"></p> </form> </body> </html>
Here is handler.php:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Π’Π΅Π³ INPUT, Π°ΡΡΠΈΠ±ΡΡ accept</title> </head> <body> <? if (empty($_FILES['img']['tmp_name'])) die('ΠΠ΅Π΄ΠΎΠΏΡΡΡΠΈΠΌΡΠΉ ΡΠΈΠΏ ΡΠ°ΠΉΠ»Π°!'); $tmp = $_FILES['img']['tmp_name']; $fname = $_FILES['img']['name']; if (!move_uploaded_file($tmp, 'wp-content/uploads/'.$fname)) die('ΠΠ΅ ΡΠ΄Π°Π»ΠΎΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΡΠΈΡΡ ΡΠ°ΠΉΠ» ΠΈΠ· Π²ΡΠ΅ΠΌΠ΅Π½Π½ΠΎΠΉ ΠΏΠ°ΠΏΠΊΠΈ'); echo '<img src="/wp-content/uploads/'.$fname.'" />'; // ΠΊΠ°ΡΡΠΈΠ½ΠΊΠ° Π·Π°Π³ΡΡΠΆΠ΅Π½Π° ?> </body> </html>
When downloading any files (I tried to download pictures and archives), he writes that the file type is invalid, although I allowed uploading pictures:
<input type="file" name="img" accept="image/jpeg,image/png,image/gif">
What is the problem then?