2

*Update: Installed MAMP Pro, reinstalled Craft, asset upload is working now. Not exactly a fix, but seemed like the simplest route of action due to my unfamiliarity with PHP. Thanks to those who responded to my question.

I'm a newcomer to web development and Craft CMS. I've downloaded and installed Craft CMS locally and I'm following along with an "Up and Running With Craft CMS" tutorial to get my bearings.

I am unable to upload assets via an asset field. The upload box appears and after selecting a file to upload the progress bar fills and freezes and the loading wheel spins on forever. Due to this I can't upload any images and therefore can't create my site properly. Please help! enter image description here

  • Check your craft/storage/runtime/logs files for the underlying error as to why the asset upload failed. 99/100 times it's an environmental configuration issue (php.ini memory_limit, max_execution_time, using GD and uploading an image format it doesn't support, etc.) – Brad Bell Mar 10 '17 at 5:50
  • Hi Brad, thank you for answering. In my craft/storage/runtime.logs files I found the following error: 2017/03/10 16:07:02 [error] [exception.Craft\HttpException.400] Craft\HttpException in /Applications/MAMP/craft/app/controllers/BaseController.php:217 What does this mean? – Shadi Mar 10 '17 at 16:17
  • If that's the message you're getting when you try and upload, then sounds like there are some issues with your server environment: craftcms.stackexchange.com/questions/16374/… – Brad Bell Mar 10 '17 at 19:04
2

This is normally caused due to a 500 error and monitoring the AJAX request using your browser's dev toolbar or using the log file craft/storage/runtime/logs should give you a clearer picture.

It's possible your missing a PHP module called GD or if you have used the CraftCMS auto-update feature sometimes it misses files.

If you are missing the GD PHP module you can install it using your prefer package manager (yum, apt-get, brew, etc) or if installed or your using XAMPP/ MAMP you can add it to your PHP.ini and it should resolve your issue.

If it's missing PHP files from an auto-update you can override/ replace the craft/app folder using the original from Github or the CraftCMS website. This option would update your CMS in the process and shouldn't be needed if its a new install/ downloaded build.

| improve this answer | |
2

Checking the logs is of course recommended:

craft/storage/runtime/logs

However, I have personally found that failed uploads are related to "write" issues where either the directory permissions are invalid or the actual upload path doesn't exist (aka invalid).

One simple way to potentially obtain more information is to look at the actual HTTP response for the "upload file" AJAX request. I often do this via Chrome's Developer Tools' Network tab.

  1. Open Chrome Developer Tools
  2. Click the "Network" tab.
  3. Perform the file upload.
  4. Click on the "uploadFile" request that was generated
  5. Click the "Response" tab to view the completed response (which will appear once the response is returned).

Chrome Developer Tools Network Tab

| improve this answer | |
  • Hi Jarrett! Thanks for answering. I tried to obtain more information via Chrome's Developer tools network tab. When I click on the uploadFile request I get the following error in the console: net::ERR_EMPTY_RESPONSE and the response tab fails to load response data. What does this mean? – Shadi Mar 10 '17 at 16:13
  • Does it give you a HTTP Response Code? (e.g. 400 or 500 error)? It's likely that you're encountering a PHP error which if that's the case, Brad Bell is likely right. Your PHP memory settings need to be adjusted OR you're running into an issue with the image handling (e.g. GD library). The next step is to check your PHP error log and/or the craft logs for an actual PHP error message. I would then use XDebug to do a stacktrace to identify the exact issue; however, that's likely not an option for you if your new to PHP development.. but a quick way for newcomers is to use MAMP Pro w/ PHPStorm EAP – Jarrett Barnett Mar 10 '17 at 18:02
  • Thanks so much for the followup. I'm absolutely new to PHP development, so this issue has been very confusing for me. In response to your question, I'm receiving a 400 error code. I've checked the craft/storage/runtime/logs and found an error but I don't know what it means. What is XDebug and how do I access it? Here's my error: 2017/03/10 16:07:02 [error] [exception.Craft\HttpException.400] Craft\HttpException in /Applications/MAMP/craft/app/controllers/BaseController.php:217 etc. etc. – Shadi Mar 10 '17 at 18:32
  • Looking at the code for that error, it seems to indicate an issue with the Request that's being generated. e.g. here's the code: if (!craft()->request->isAjaxRequest()){ throw new HttpException(400); } Can you perform the request again and instead of viewing the "Response" tab, can you send the Request information located in the "Headers" tab (as seen in the previous screenshot)? – Jarrett Barnett Mar 10 '17 at 21:53
  • Also found this question and answer that could be the issue you're encountering as well: craftcms.stackexchange.com/questions/16374/… Which would indicate an issue with the server your website is hosted on. As for XDebug, it's more of an advanced tool and too complicated to explain in a StackExchange comment, but look-up a XDebug video tutorial. If you take the time to set it up, learn it and use it, you'll go far. – Jarrett Barnett Mar 10 '17 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.