PasteImgUpload

Summary: Upload an image by copying and pasting in the editing area directly.
Version: 20250417
Prerequisites: Chrome or Edge browser, JavaScript
Status: Only works with Chrome and Edge
Maintainer: LSMeng
License: GPL3+
Categories: Uploads Editing Images
Users: (view? / edit)

All sections are optional, you can remove those that do not apply to your recipe, and add new ones.

Description

Demo available at Jsfiddle:
https://jsfiddle.net/a703d2q3/1/

This recipe enables direct copy and paste to upload an image using Javascript AJAX. Images copied from the Internet, image editing tools, or an image file are all supported. A little animation is shown on upload success. The uploaded image is automatically given a filename being the formatted current time. The default markup for uploading is also automatically pasted with filled filename as Attach:YYYYMMDD_HHMMSS.png. On upload failure, an alert message is shown with response sent from the server. Note that this recipe has only been tested in Chrome and Edge.

Note that this recipe can work with DragDropMultiUpload. ( include it before DDMU.)

Installation

  • Enable upload in local/config.php
    $EnableUpload = 1;
  • Download pasteimgupload.zipΔ
  • Place pasteimgupload.php in your /cookbook/ directory, the /pasteimgupload/ dir with all files in your /pub/ directory.
  • Add to local/config.php this line:
    include_once("$FarmD/cookbook/pasteimgupload.php");

Change log / Release notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

  • 20160729 - first release.
  • 20250417 - Updated to work with Chrome and Edge pasteimgupload.txtΔ, rename to pasteimgupload.js

Contributors

  • Recipe written and maintained by LSMeng.

See also

Comments

See discussion at PasteImgUpload-Talk.

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.