Prises de notes

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
dev_web [2018/10/11 11:41] nororedev_web [2024/01/11 12:42] (Version actuelle) – supprimée norore
Ligne 1: Ligne 1:
-====== Uploader une photo recadrée à la volée ====== 
  
-===== Requis ===== 
- 
-  * Croppies.js 
-  * PHP 
-  * HTML 
-  * CSS 
- 
-===== Qu'est-ce qui est appris ? ===== 
- 
-Jouer avec base64. 
- 
-===== Code source ===== 
- 
-==== Javascript ==== 
- 
-<code javascript> 
-$uploadCrop = $('#prev_photo').croppie({ 
-    enableExif: true, 
-    viewport: { 
-        width: 300, 
-        height: 400 
-    }, 
-    boundary: { 
-        width: 400, 
-        height: 400 
-    } 
-}); 
- 
-$('#scolarite_biologiebundle_etudiants_individu_photo').on('change', function () { 
-    var input = $(this)[0]; 
-    if (input.files && input.files[0]) { 
-        var reader = new FileReader(); 
-                 
-        reader.onload = function (e) { 
-                            $uploadCrop.croppie('bind', { 
-                                url: e.target.result 
-                            }).then(function(){ 
-                                console.log('jQuery bind complete'); 
-                            }); 
-                        } 
-        reader.readAsDataURL(input.files[0]); 
-    } 
-    else { 
-        alert("Sorry - you're browser doesn't support the FileReader API"); 
-    } 
-}); 
- 
-$('#scolarite_biologiebundle_photoetudiant_photo').on('change', function () { 
-    var input = $(this)[0]; 
-    if (input.files && input.files[0]) { 
-        var reader = new FileReader(); 
-                 
-        reader.onload = function (e) { 
-                            $uploadCrop.croppie('bind', { 
-                                url: e.target.result 
-                            }).then(function(){ 
-                                console.log('jQuery bind complete'); 
-                            }); 
-                        } 
-        reader.readAsDataURL(input.files[0]); 
-    } 
-    else { 
-        alert("Sorry - you're browser doesn't support the FileReader API"); 
-    } 
-}); 
- 
-function showResult(result) { 
-    if (result.src) { 
-        var img = result.src; 
-        $('#prep_photo').attr('src', img); 
-    } 
-    if (result.blob) { 
-        var img = result.blob; 
-        $('#photocoupee').attr('value', img); 
-    } 
-} 
- 
-$('#prev_photo').on('update.croppie', function(ev, cropData) { 
-    $uploadCrop.croppie('result', { 
-                            type: 'canvas',  
-                            size: 'viewport', 
-                        }).then(function (value) { 
-                            showResult({src: value}); 
-                        }); 
-}); 
- 
-$('#prev_photo').on('update.croppie', function(ev, cropData) { 
-    $uploadCrop.croppie('result', { 
-                            type: 'canvas',  
-                            size: 'viewport', 
-                        }).then(function (value) { 
-                            showResult({blob: value}); 
-                        }); 
-}); 
-</code> 
- 
-==== Rendu HTML ==== 
- 
-==== PHP ==== 
dev_web.1539258108.txt.gz · Dernière modification : de norore