UploadedFile->saveas() generate corrupted file only in windows

Hi all, i’m deploying a new api for my webapp. It receive a file with post (i use google postman for test) and save it locally in a directory.

I have a local environment with windows and remotly online version with linux, both with the same code

LOCAL (Windows 10 64 bit - Php - Apache)

Each file i send (image/text/document) is saved locally corrupted. I can’t open. The file has the same size, name, extension of the original, but has something wrong.

REMOTE (Linux Ubuntu - Php - Apache)

Works fine. The local copy is the same of the original and can be well opened.

Can you give me any idea on what can i check?

I don’t know if the problem is getting the file from the post call that for some reason could be corrupted during the reception.

Or during the save operation, there’s some environment variable that let write a wrong file.

Thank’s for any suggestion.

What do you mean by “can’t open”? Do you say that you couldn’t open a plain text file (“readme.txt”, for example) with the original file size, name and extension? Or do you mean to say that the content was corrupted?

I would send a simple text file with some simple words and check the content in the post and in the saved file.

Hi softark, i try to send a simple txt file and try to open with Notepad++ but i have the message: "Can not open the file"

So i try to open with simple Windows/notepad and i have the message “You don’t have authorization to open this file.”

And this is at least an indication.

If i try on Windows to copy and paste the file, the system prompt for admin authorization. If i confirm (of course i’m administrator) the new file copied works fine. I could open both txt file and images.

So, what i understand for now, is that could be an authorization problem when my application save the file.

I don’t know (and i’m looking for it) where to configure it in php under windows.

Any ideas?


OK i solve this problem.

After many research, i find that is a problem of Apache Services configuration under my Windows.

Following these steps , now my Apache Service runs as Administrator under my Windows and now my app save "good" files with the right auth permission that could be opened.


Happy to hear you solved it. Congrats! :)