In the file_save_upload documentation (and also in any other version) you can read, in the parameters explain:
$replace A boolean, set to true if the destination should be replaced when in use, but when false append a _X to the filename.
But if you pass this parameter to the function as boolean TRUE value, you will get an error. This is because file_save_upload calls file_move, that calls file_copy. If you pass $replace as TRUE to file_copy, in the switch statement it will falls to first case != 0, ie: case FILE_EXISTS_ERROR, but case FILE_EXISTS_REPLACE is expected
As log as I think that $replace=TRUE | FALSE in file_save_upload makes sense, and I think that is file_move the function that is not working as expected, I'd add some code to the switch statement in file_move to fix this. (see patch)
greetings!
| Comment | File | Size | Author |
|---|---|---|---|
| file.inc_.patch | 550 bytes | nacho.mg |
Comments
Comment #1
mscdex commentedI was having this exact same problem. I applied the supplied patch and my file uploads in my form work perfectly now! Thanks!
Comment #2
drummActually, the documentation is wrong for file_save_upload(). The $replace argument's documentation should match file_save_data(), file_copy(), and file_move() and suggest using the constants.
Comment #3
dpearcefl commentedDue to the age of the last comment on this issue and due to the fact that D5 is no longer supported, I am closing this issue.