Hot answers tagged

47 votes
Accepted

413 “Request Entity Too Large” error with uploading a file

413 errors occur when the request body is larger than the server is configured to allow. Here’s how you can fix it, depending on your web server: Apache: Set the LimitRequestBody directive in either ...
7 votes
Accepted

Does Craft enforce a maximum filesize for large files?

The only thing Craft enforces is the maxUploadFileSize config setting, which by default is set to 16MB. Outside of that, any limitations you run into will be environmental/server config related.
  • 66.5k
6 votes
Accepted

Upload file from plugin's Controller to a non-Assets folder

Ahh, a bit of fiddling and poking around later... $file = UploadedFile::getInstanceByName('myFieldName'); $fileName = AssetsHelper::cleanAssetName($file->getName()); // Make fileName uniqueish by ...
6 votes

Upload file size limits to 256MB

When determining the maximum upload file size, Craft first takes the php.ini file upload_max_filesize, post_max_size and memory_limit into account by getting the minimum value and only then applying ...
  • 66.5k
6 votes

How to rename filename of asset before (or after) upload in Craft 3

Well, after searching for this for more than 2 hours, I bumped into a working solution; Event::on( Elements::class, Elements::EVENT_AFTER_SAVE_ELEMENT, function(ElementEvent $event) { ...
  • 141
5 votes

Upload any size image into carousel

You shouldn't need to create a custom plugin to do that. You can easily create a Matrix content field for your carousel. Create a new block called slide. From there you can create an asset field to ...
5 votes
Accepted

Error uploading .bmp file format - gets rejected

You're probably using GD, which doesn't support BMP files. If you install Imagick on your server, Craft will use it automatically and it supports a much wider range of file types, including BMP ...
  • 66.5k
5 votes
Accepted

Images containing EXIF orientation tag are not rotated on upload

After some mail exchanges with Brad and Andris from Craft CMS, it turned out that there is an edge case where the image rotation on upload will not work if the EXIF extension is not installed (which ...
  • 496
4 votes
Accepted

Craft 2.2 with enabled enableCsrfProtection: Failed to load resource: the server responded with a status of 400 (Bad Request)

I can confirm this is a bug on Craft 2.2.2579 when CSRF protection is enabled. Will get a fix out for it shortly and update this answer when it's done. Update: Fixed in Craft 2.2.2582.
  • 66.5k
4 votes
Accepted

Hosting Craft on Heroku, problems with Asset uploads and thumbnail generation

I solved the problem by setting the client_max_body_size to, in my case, 20M. Did this using the following nginx_app.conf location / { # try to serve file directly, fallback to rewrite ...
4 votes
Accepted

Custom field type file upload error [Uploaded File Class]

Yii’s CUploadedFile class actually doesn’t support retrieving uploaded files that came from a file input whose name was “namespaced” (e.g. name="fields[handle]" rather than just name="handle"). ...
4 votes

How do I upload photos into my assets list/library?

Have you created that directory? If not, you need to. Also be sure the directory you create has the correct permissionss (writable by the web server)
4 votes
Accepted

How to control the format of an asset's Title

For Craft 2, You can write a plugin that listens to the onBeforeSaveAsset event, and changes the title from the asset parameter to whatever you want. Something like: if ($event->params['isNewAsset]...
  • 66.5k
4 votes

Adding images directly to public folder

You need to use the Update Asset Indexes tool in Settings in the control panel: Whenever there are files within your asset source that were not added directly by Craft (e.g. via FTP), you will need ...
4 votes
Accepted

Error on upload: "Impossible to create the root directory..."

I understand now within the context of you are using docker. Since docker creates a new file system separate from your computer's file system, you will want to run these commands on the docker ...
3 votes
Accepted

Uploaded images stripped of EXIF data

Currently the images are being cleansed on upload, which means that they are being re-saved to make sure that no malicious code is injected in them. Unfortunately, this means that EXIF data gets ...
3 votes

Upload and crop profile photo in frontend

This is a very old question, but thanks to this example I was able to build quickly a profile picture form using Craft 3 and jQuery File Upload plugin (thank you!). The action value and file input ...
3 votes
Accepted

File upload error. Cannot upload .key (keynote) files

It looks like .key files are not included in the default allowed file extensions. But you can manually add it with the extraAllowedFileExtensions setting in your config/general.php file: '...
  • 35.9k
3 votes

Uploaded photos not showing on entry

It looks like you're trying to access another asset within your assets (asset meta field). {% set photos = entry.photos %} {# Loop assets of `entry.photos` as `photo` #} {% for photo in photos %} ...
  • 35.9k
3 votes

How to process CSV files within a Matrix field?

You're not overlooking anything. What you're asking for is not a core feature of Craft and probably will never be. There's also no plugin yet that does something like this. So the only answer I can ...
  • 35.9k
3 votes
Accepted

Unable to upload PNG images

Is there anything special about that PNG file? It's likely that it's in a PNG format that GD does not support. Install Imagick and try again. It handles a much wider range of formats, is generally ...
  • 66.5k
3 votes

Unzip zipped file after upload

I'm 99% sure the answer is yes, that's doable, although you'd need a custom plugin to handle the bulk of it. You'd need to write some PHP to handle the unzip, and place the files where you want them. ...
  • 23.6k
3 votes

How to upload several images & automatically create an entry for each one?

I was going to suggest using the very handy Import plugin, but I see that it only supports entries, categories, and users. And unfortunately, I don't see another plugin that does this specifically. ...
3 votes

How can I get a restricted Asset Allowed File Type upload to accept RTF files

Does this help you? It'll let you add additional file extensions that are allowed to be uploaded. http://buildwithcraft.com/docs/config-settings#allowedFileExtensions
  • 566
3 votes

Image upload failed- file not writable

On the server, check: if the folder exists? Check the folder permissions are set to 777 (could probably reduce to 755) Within Craft: In: Settings > Assets > Asset Sources - make sure File System ...
  • 1,538
3 votes
Accepted

Dynamic Subfolders leaving empty folders behind

When Assets moves files around because of dynamic Assets folder changes, it does not remove empty folders. On the surface it seems like a no-brainer - just check if the folder is empty and if so, ...
3 votes

Upload Image Custom Field

I believe you are looking for the Assets Field
  • 13.3k
3 votes
Accepted

How does Craft handle uploading assets to AWS?

They are uploaded to Craft first to a temporary file, then Assets uses the Asset Source to work out where to send them next - either the local file system or a remote one. For handling large uploads ...
  • 2,301
3 votes
Accepted

Front end assets uploading, does not appear to be a an image error

The issue lies if you have a Preparse field in that field layout, see details here: https://github.com/aelvan/Preparse-Field-Craft/issues/23
  • 3,061
3 votes

Upload file size limits to 256MB

Apparently, Craft requires memory_limit to also be set to max value, so setting memory_limit in php.ini did solve my problem.
  • 555

Only top scored, non community-wiki answers of a minimum length are eligible