I am trying to upload a file and then save it by changing its name. However, this does not work and gives me this error.
Warning: move_uploaded_file (uploads / 564b68ef0e2f8 | 3d-pc-nature-wallpaper.jpg): stream could not be opened: invalid argument in C: \ wamp \ www \ f \ ajax.php on line 157
Warning: move_uploaded_file (): Unable to move 'C: \ wamp \ tmp \ phpA364.tmp' to 'uploads / 564b68ef0e2f8 | 3d-pc-nature-wallpaper.jpg 'in C: \ wamp \ www \ f \ ajax.php on line 157
I checked and the file will go into $ _ FILES correctly. Here is my code.
$rand_img = uniqid(); $file_upload_folder = "uploads"; $finalImgLink = $file_upload_folder . '/' . $rand_img . '|' . $_FILES['file']['name']; //move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/$rand_img|' . $_FILES['file']['name']); if(move_uploaded_file($_FILES['file']['tmp_name'], $finalImgLink)) { echo "ok"; } else { echo "not ok"; }
What is wrong here?
user5542300
source share