Answer the question
In order to leave comments, you need to log in
How to implement uploading files to server [php/apache]?
Worth OpenServer . The file upload form is written correctly. The file seems to be loading, I look at the dump, everything is in order there:
string(14) "H:\phpD394.tmp"But the file, as such, is not there. What could be the problem? In the PHP config I edit the temporary directory - infa from the dump changes but the file is not observed. All this happens under Windows.
Answer the question
In order to leave comments, you need to log in
Do I misunderstand that "at the end of the script, if the received file has not been renamed or moved, it will be automatically deleted from the temporary folder"? That is, you should use the move_uploaded_file function as suggested.
<?php
define('GW_UPLOADPATH', 'images/');
$name=$_POST['name'];
$score=$_POST['score'];
$pic = $_FILES['screenshot'];
$pic=move_uploaded_file($_FILES['screenshot'], GW_UPLOADPATH);
?>
bool(false)
string(14) "H:\phpEB58.tmp"Is it supposed to save the file like this, or should the name match the file?
@Nc_Soft please:
Array ( [screenshot] => Array ( [name] => WIN_20131201_052047.JPG [type] => image/jpeg [tmp_name] => H:\phpB65.tmp [error] => 0 [size] => 122294 ) )
Hmm ... as I understand it, when trying to move, he swears:
Warning: move_uploaded_file(C:/srv/OpenServer/domains/localhost/images/) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\srv\OpenServer\domains\localhost\tmp\addscore .php on line 29
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'H:\phpABBE.tmp' to 'C:/srv/OpenServer/domains/localhost/images/' in C: \srv\OpenServer\domains\localhost\tmp\addscore.php on line 29
?php
$name=$_POST['name'];
$score=$_POST['score'];
$uploads_dir = '/images';
$tmp_name = $_FILES["screenshot"]["tmp_name"];
$name = $_FILES["screenshot"]["name"];
move_uploaded_file($tmp_name, "$uploads_dir/$name");
if ($_POST['submit']==true) {
$mysqli->query("INSERT INTO guitar VALUES(0, NOW(), '$name', '$score', '$pic')");
}
?>
Warning: move_uploaded_file(/images/WIN_20131204_232139.JPG) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\srv\OpenServer\domains\localhost\tmp\addscore.php on line 35
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'H:\php49F4.tmp' to '/images/WIN_20131204_232139.JPG' in C:\srv\OpenServer\domains\localhost\tmp\ addscore.php on line 35
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question