When I run this php file it executes everything except the move_uploaded_file. It produces the following Warnings:
warning: move_uploaded_file(uploadsFlowers002.JPG<br>): failed to open stream: Invalid argument in C:\xampp\htdocs\tutorials\filehandeling\upload.php on line 20
Warning: move_uploaded_file(): Unable to move 'C:\xampp\tmp\php43D.tmp' to 'uploadsFlowers002.JPG<br>' in C:\xampp\htdocs\tutorials\filehandeling\upload.php on line 20
The php file location is C:\xampp\htdocs\tutorials\filehandeling.
The move to location is C:\xampp\htdocs\tutorials\filehandeling\uploads.
I think $location$tmp_name$name are valid declared variables.
So, I don't understand invalid argument on line 20.
I suspect this problem is due to trying to move selected file to the uploads folder.
I've tried the following: $location=C:\xampp\htdocs\tutorials\filehandeling\uploads
$location=C:\xampp\htdocs\tutorials\filehandeling
$location='\uploads';
$location='/uploads';
$location='uploads\';
$location='uploads/';
$location='uploads';
I've also tested with different file type, such as: .txt and got the same warning
Don't know what else to do.
<html>
<form action="upload.php" method="POST" enctype="multipart/form-data">
<input type ="file" name ="file"><br><br>
<input type ="submit" value="submit">
</form>
</html>
<?php
echo 'File name:   ', $name = $_FILES ['file'] ['name'].'<br>';
echo 'File size:   ', $size = $_FILES ['file'] ['size'].' '.'kb'.'<br>';
echo 'File type:   ', $type = $_FILES ['file'] ['type'].'<br>';
echo 'Temporary file location:   ',$tmp_name =$_FILES ['file'] ['tmp_name'];
if(isset($name)) {
if (!empty($name)) {
$location = 'uploads';
if (move_uploaded_file($tmp_name, $location. $name)) {
echo '<br>File that was <strong><font color="red">UPLOADED</font></strong>';
}
} else {
echo 'Please choose a file';
}
}
?>
Any help would be greatly appreciated.