I'm currently using XAMPP on MAC OS X and have the appropriate configuration in my php.ini
to enable file uploading.
After performing an upload via an HTML form, when I display the array for $_FILES, I see the following:
Array
(
[name] => koopa.jpg
[type] => image/jpeg
[tmp_name] => /Users/jay/Sites/uploads/php5QJtL3
[error] => 0
[size] => 14158
)
As shown, the error code is [0], which is an indication that the file was successfully uploaded. However, the contents of /Users/jay/Sites/uploads/ is completely empty.
I've gone through the iteration of the following users for the folder ownership: root, jay, nobody, zend, and restarting XAMPP for every time I change the folder ownership. I've also set the permissions of that folder to 777.
Yet, I am still unable to see/find the uploaded file.
Has anyone else had this same problem?
I think that you are missing something, may i guess that you have uploaded the file but you have not stored it?
I'll paste some example code for you just to be sure you are doing it the rigth way:
for ($i = 0; $i < sizeof($_FILES['file']['name']); $i++) {
$target_path = 'your/upload/path/';
$file_name = 'file_name_including.extension'
$full_path = $target_path.$file_name;
if(move_uploaded_file($_FILES['file']['tmp_name'][$i], $full_path) {
echo 'file uploaded correctly';
} else {
echo 'something went wrong';
}
}
Tell me if this helped you.
Regards
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.