Yii Framework Forum: UploadedFile->saveas() generate corrupted file only in windows - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

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

#1 User is offline   Federico Benedetti 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 11-June 14
  • Location:Italy - Pesaro

Posted 31 December 2017 - 05:28 AM

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.
0

#2 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 3,498
  • Joined: 16-February 11
  • Location:Japan

Posted 31 December 2017 - 06:45 AM

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?

Quote

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.

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

#3 User is offline   Federico Benedetti 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 11-June 14
  • Location:Italy - Pesaro

Posted 31 December 2017 - 08:50 AM

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?
Thank's

View Postsoftark, on 31 December 2017 - 06:45 AM, said:

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.

0

#4 User is offline   Federico Benedetti 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 11-June 14
  • Location:Italy - Pesaro

Posted 31 December 2017 - 10:02 AM

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.

Thank's
1

#5 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 3,498
  • Joined: 16-February 11
  • Location:Japan

Posted 31 December 2017 - 01:49 PM

Happy to hear you solved it. Congrats! :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users