Php create zip file (from post attachments wordpress)

后端 未结 1 1070
北海茫月
北海茫月 2021-01-05 21:34

I am trying to create a zip file from post attachments in wordpress .

I have tried both methods below - but it results in nothing (No error messages , no file create

1条回答
  •  有刺的猬
    2021-01-05 21:47

    Ok - I will answer my own question here ..

    I have confirmed my own suspicions - PHP can not create ZIP when passed over HTTP - so we need a PATH and not a URL ...

    So for example in Wordpress case, need to use get_attached_file() to produce real path ..

    Array ( 
    [0] => C:\Documents and Settings\OB\htdocs\test_env\wp-content\uploads\2012\03\wrt-62316IMAG0659.jpg 
    [2] => C:\Documents and Settings\OB\htdocs\test_env\wp-content\uploads\2012\03\wrt-85520_IGP0255.jpg
    [3] => C:\Documents and Settings\OB\htdocs\test_env\wp-content\uploads\2012\03\wrt-85520_IZTP0635.jpg
    [4] => C:\Documents and Settings\OB\htdocs\test_env\wp-content\uploads\2012\03\wrt-85520_ITG035t5.jpg
    [5] => C:\Documents and Settings\OB\htdocs\test_env\wp-content\uploads\2012\03\wrt-85520_IRTT7375.jpg )
    

    (Thanks @DaveRandom for his comment about seeing the var_dump array -I had actually looked at it many times, but until someone specifically asked to see it I did not pay much attention.)

    Then it made me remember another problem I had long time ago with gdlib - about PHP stream functions , creating files - and HTTP. For example image libraries like gdlib, or pdf dynamic creation they all fail on HTTP.

    0 讨论(0)
提交回复
热议问题