0

I have a project where I'm using Laravel Excel to import a spreadsheet, this aspect is completely fine.

If I download a file from the internet to my downloads folder and then try to import that file, I get an empty array [ ]. When I open the file in Excel it says that it is open in protected view. If I then enable editing and resave this file it then becomes readable.

To replicate my issue you can do the following:

  1. Download an Excel file from an external source to a Windows machine
  2. Attempt to import the file like so $importData = (new CustodianUsersImport)->toArray($request->file('upload'));
  3. Die and dump $importData, it should be null.
  4. Open the file in Excel, disable protected view and resave it
  5. Attempt to re-import. The dd() should contain an array.

My question is, is it possible to remove the protection before reading?

3
  • 1
    This is a Windows feature. On a downloaded file — right-click > properties > general > unblock. There are ways to this disable this protection for all downloads if you really want to, though probably not recommended. Commented Nov 9, 2021 at 5:41
  • @matticustard the weird thing is, is I open the file and re-save it to my desktop it works absolutely fine. Unsure if resaving removes some unknown protection? Commented Nov 9, 2021 at 11:10
  • 1
    Assuming you are opening the file in Excel, you should be prompted with various ways to remove this protection. "Enable Editing", "Enable Saving", etc. This action is what removes the protection. Commented Nov 9, 2021 at 14:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.