Skip to content

syntaxbender/image-uploader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTML5 Javascript Image Uploader

Usage

First import javascript file.

<script type="text/javascript" src="assets/js/sbImageUploader.js"></script>

Add image container div inside body tags.

<body>
...
.
.

<div class="sbImageContainer"></div>

.
.
...
</body>

Call init method, it will be ready for use.

sbImageUploader.init();

Inıt method with additional parameters.

sbImageUploader.init();
{
	uploadButtonText : "Yükle",
	startNumber : 3,
	maxImageNumber : 10,
	contentTypeErrorMessage : "Yalnızca jpeg, gif, bmp ve png dosyaları yükleyebilirsiniz.",
	acceptableTypes : ["image/gif", "image/jpeg", "image/png","image/bmp"],
}

Get uploaded files with get method.

sbImageUploader.get();

Notes

Need json array output from backend.

  • First element of array indicate as boolean, upload succes or fail.
  • Second element of array indicate uploaded image filename.

Example output :

[true,"img.jpg"]

The next commits targets

  • Register done function after image uploads.
  • Store filename received from backend or client.
  • Upload error message from backend.
  • Improvement for style.css, right now like a trash.