0

I am using answer of this question to convert docx to text file

How to extract text from word file .doc,docx,.xlsx,.pptx php

but it returns false beacause value of $zip is 11. as I undestood 11 means it can not open file. I use a url like this as $filename.

http://saha.com/wp-content/uploads/2/4/7/2016/07/test.docx

Could be it wrong ?

I tested it local and it works correctly with same url but when I use in wordpress as plugin I get error .

Community
  • 1
  • 1
faraa
  • 575
  • 3
  • 14
  • 42
  • PHP does have configuration options to block access to URLs by means of file handling functions. – arkascha Jul 31 '16 at 07:09
  • @arkascha could you explain more? what should i do? – faraa Jul 31 '16 at 07:16
  • If you take a short look into the official documentation you will see the conditions required for different attempts to open a file by means of (for example) the `fopen()` function: http://php.net/manual/en/function.fopen.php: "PHP will check to make sure that `allow_url_fopen()` is enabled" That is one of many PHP configuration options. Check it. It often is turned _off_ due to security issues. – arkascha Jul 31 '16 at 07:19
  • @arkascha but i can't find same thing for zip_open – faraa Jul 31 '16 at 07:26
  • oh... why do you think that `zip_open()` can be given a URL as argument to load a _remote_ file? AFAIK you have to copy it and then open the local file... – arkascha Jul 31 '16 at 07:29
  • @arkascha what does mean local here? Do you mean I should copy remote file in some place like wp_content and then use it? – faraa Jul 31 '16 at 07:37
  • Local does indeed mean the local file system (on the "server"). I am a bit surprised that you say you are able to use a URL with that function on your local system. I never heard of that, actually, but then again one never stops to learn :-) You will find many examples of how to copy and then open the file. But as said: if you can actually use that function with a URL as argument then that _would_ be very convenient... – arkascha Jul 31 '16 at 07:42
  • @arkascha you are right. I should copy it first.plz add your answer so I will accept it.Thank you so much – faraa Jul 31 '16 at 09:35
  • 1
    I didn't really provide an answer. I only hinted and guessed :-) Have fun! – arkascha Jul 31 '16 at 09:43

0 Answers0