<FORM ENCTYPE="multipart/form-data" ACTION="4_1_action.php" METHOD="POST"> <INPUT NAME="file" TYPE="file"> <INPUT name="ok" TYPE="submit" value="ΠΠ΅ΡΠ΅Π΄Π°ΡΡ ΡΠ°ΠΉΠ»"> </FORM> <?php if(isset($_FILES["file"])) { $catalog = "image"; if (is_dir($catalog)) { $myfile = $_FILES["file"]["tmp_name"]; $myfile_name = $_FILES["file"]["name"]; if(!copy($myfile, $catalog)) echo "ΠΡΠΈΠ±ΠΊΠ° ΠΏΡΠΈ ΠΊΠΎΠΏΠΈΡΠΎΠ²Π°Π½ΠΈΠΈ ΡΠ°ΠΉΠ»Π° ".$myfile_name; } else mkdir('image'); } ?> When you select a file and press the button, it gives an error:
Warning: copy () [function.copy]: you canβt get a directory in Z: \ home \ prakt \ www \ 4_1_action.php on line 9 Error copying file 04.jpg
Tell me what's wrong?
copy- Copies the source file to a file named dest ....... and you bother it with the second parameter ..... Fill in the end with a slash and a name. - Alexey Shimansky/imagesmay be needed, or maybemysupersite/cawabunga/images..... depending on the structure of the project and how the routing is configured ..... because this was the only error .... almost ... yourelseredundant .... you can write like thisif (!is_dir($catalog)) mkdir('image'); $myfile = $_FILES["file"]["tmp_name"]; $myfile_name = $_FILES["file"]["name"]; if(!copy($myfile, $catalog.'/'.$myfile_name)) echo "ΠΡΠΈΠ±ΠΊΠ° ΠΏΡΠΈ ΠΊΠΎΠΏΠΈΡΠΎΠ²Π°Π½ΠΈΠΈ ΡΠ°ΠΉΠ»Π° ".$myfile_name;if (!is_dir($catalog)) mkdir('image'); $myfile = $_FILES["file"]["tmp_name"]; $myfile_name = $_FILES["file"]["name"]; if(!copy($myfile, $catalog.'/'.$myfile_name)) echo "ΠΡΠΈΠ±ΠΊΠ° ΠΏΡΠΈ ΠΊΠΎΠΏΠΈΡΠΎΠ²Π°Π½ΠΈΠΈ ΡΠ°ΠΉΠ»Π° ".$myfile_name;where aftermkdir('image');need to pressenter- Alexey Shimansky