anvc / scalar

Born-digital, open source, media-rich scholarly publishing that’s as easy as blogging.
Other
231 stars 73 forks source link

Media import silently fails (HTTP 200) #61

Closed timoguic closed 7 years ago

timoguic commented 7 years ago

Hello,

We are running Scalar on Apache + PHP-FPM (v5). When trying to upload a book cover or to import local media into a book, the upload fails.

When changing the book cover, after the upload I am redirected to the dashboard page (system/dashboard). I can see the following log lines: [31/Mar/2017:09:26:26 +0000] "POST /system/dashboard HTTP/1.1" 200 892 "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"

(I removed the referrer but it comes from "/system/dashboard?book_id=7&zone=style")

When using "import local media", if I click on Upload the button becomes deactivated, I see some lines in the log file but nothing happens: [31/Mar/2017:09:25:08 +0000] "GET /my_book_name/upload HTTP/1.1" 200 5445 "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36" [31/Mar/2017:09:25:20 +0000] "POST /my_book_name/upload HTTP/1.1" 200 896 "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"

Any suggestions? Thanks!

craigdietrich commented 7 years ago

Hi @timoguic,

It sounds like the filesystem doesn't have the proper write permissions on the Scalar book's folder. Meaning, PHP needs to have write access to the folder that Scalar is in (the Scalar root folder) and all of the folders that Scalar creates that correspond to each book. Scalar should set every new folder it creates to 0775, which usually does the trick, but maybe PHP doesn't have the permission to chmod on your system? I think the flag to pass file permissions from the parent to the child automatically is +s.

As for it failing gracefully, take a look at the front controller ("codeigniter.php" in the root folder). Here you can set 'production' to 'development' which should turn on PHP errors if your server allows them. Otherwise, you could up the log threshold in system/application/config/config.php.

Hope this helps!

timoguic commented 7 years ago

Thanks a lot! I turned on the development setting and it complained about the PHP function createimagefromjpeg. Turned out I didn't have the gd module active in my PHP config. Problem solved, thanks again!

craigdietrich commented 7 years ago

Great news!