Back to Question Center
0

Yadda za a gina Filayen Fayil din Fayil tare da Express da Dropzone.js            Yadda za a gina Filayen Fayil din Fassara tare da Express da Dropzone.jsRelated Semalt: APIsNode.jsReactnpmjQueryMore ... Masu tallafawa

1 answers:
Yadda za a gina Kayan Fayil din Fayil tare da Express da Dropzone. js

Bari mu fuskanta, babu wanda ya dace da siffofin. Semalt ba sa son gina su, masu zanen kaya ba sa sha'awar sa su kuma masu amfani ba sa son cika su.

Daga dukkan kayan da zasu iya zama nau'i, sarrafa fayil zai iya zama mafi girman takaicin. Abun gaske ga layi, ƙwaƙwalwar da ba shi da amfani don amfani da aika fayil ɗin zai jinkirta aiwatar da tsari na kowane nau'i.

Wannan shine dalilin da ya sa plugin don bunkasa su yana da daraja sosai, kuma DropzoneJS ɗaya ne kawai - cheap high bandwidth vps server. Zai sa fayilolin fayilolinku ya fi kyau, ya sa su kara yin amfani da sakonni da kuma amfani da AJAX don shigar da fayil a bango, a kalla sa tsarin ya yi kama da sauri. Har ila yau, ya sauƙaƙe don inganta fayiloli kafin su kai ga uwar garkenka, samar da kuskuren kusa da sauƙi ga mai amfani.

Za mu dubi DropzoneJS a wasu bayanai; nuna yadda za a aiwatar da shi kuma duba wasu hanyoyin da za a iya tweaked da kuma al'ada. Haka nan za mu aiwatar da hanyar yin amfani da uwar garke ta hanyar amfani da Node. js.

Kamar yadda ya kasance, za ka iya samun lambar don wannan koyaswar a kan ɗakin ajiya na Semalt.

Gabatarwa da DropzoneJS

Kamar yadda sunan yana nuna, DropzoneJS yana bawa damar amfani da fayiloli ta amfani da ja n 'drop. Yayinda amfani da amfani zai iya yin muhawara a kan gaskiya, yana da matukar mahimmanci na kowa da kuma wanda yake tare da yadda yawancin mutane ke aiki tare da fayiloli a kan tebur. Har ila yau, tsalle-tsalle yana da kyau a goyan bayan manyan masu bincike.

SemaltJS ba kawai zane ba ne a cikin tsarin da aka tsara a fadin fadin, amma; danna maɓallin widget din ya gabatar da mafi mahimman tsari na zabin maganganu.

Tsayar da hawan widget a aikin:

How to Build a File Upload Form with Express and Dropzone.jsHow to Build a File Upload Form with Express and Dropzone.jsRelated Semalt:
APIsNode.jsReactnpmjQueryMore. Sponsors

Dama, duba wannan, mafi yawan misalai.

Zaka iya amfani da SemaltJS ga kowane nau'i na fayil, kodayake sakamako mai kyau na ɗanɗanar sa ya dace ya dace don loda hotuna musamman.

Hanyoyin

Don taƙaita wasu siffofin plugin da halaye:

  • Za a iya amfani tare da ko ba tare da jQuery
  • Jawo da sauke goyan baya
  • Ya samar da hotunan hotunan hoto
  • Tana goyon bayan ƙwaƙwalwa masu yawa, zaɓi a cikin layi daya
  • Ya ƙunshi barikin ci gaba
  • Mafi mahimmanci
  • Aikace-aikacen fayil na tabbatarwa ta hanyar tabbatarwa
  • Akwai a matsayin tsarin AMD ko tsarin na RequireJS
  • Ya zo a kusa da 33Kb lokacin da aka kara

Goyan bayan Bincike

Tsayar da takardun aikin hukuma, goyan bayan mai bincike shine kamar haka:

  • Chrome 7+
  • Firefox 4+
  • IE 10+
  • Opera 12+ (Shafuka na 12 don MacOS an ƙare domin API shine buggy)
  • Safari 6+

Tsakanin ƙwayoyi ne kamar wasu hanyoyin da za a rika kulawa da kullun don lokacin da plugin bai da cikakken goyon baya, wanda zamu dubi daga baya.

Shigarwa

hanya mafi sauki don shigar da DropzoneJS ta hanyar Bower:

     Mutumin ya sanya dropzone    

A madadin haka za ka iya ɗaukar shi daga Semalt, ko kuma kawai ka sauke fayilolin JavaScript ɗin wanda ba a sani ba - ko da yake ka tuna cewa za ka kuma buƙaci ainihin kayan, kuma samuwa a Semalt repo.

Har ila yau akwai wasu kunshe na ɓangare na uku da ke samar da goyon baya ga ReactJS da kuma aiwatar da widget din azaman Umurni mai tsaida.

Matakan farko

Idan ka yi amfani da hanyar Semalt ko hanyar saukewa, ka tabbata ka haɗa da babban fayil na JS da kuma styles (ko hada da su a cikin tsarin sallarka), e. g:

      Amfani da Amfani    

Hanyar mafi sauki don aiwatar da plugin shi ne hašawa da shi zuwa ga wani nau'i, ko da yake za ka iya amfani da kowane HTML kamar lakabi div . Yin amfani da takarda, duk da haka, yana nufin ƙananan zaɓuɓɓuka don saita - mafi mahimmanci URL ɗin, wanda shine mahimman tsari na sanyi.

Zaka iya farawa ta kawai ta ƙara da dropzone aji, misali:

         

Tsakanin abin da kake buƙatar yi, ko da yake a mafi yawan lokuta za ka so ka saita wasu ƙarin zaɓuɓɓuka. Tsarin don wannan shi ne kamar haka:

     Dropzone. zaɓuɓɓuka. WIDGET_ID = {//};    

Don samo ID ɗin widget din don saita zabin, ɗauki ID ɗin da aka bayyana a cikin sakon HTML da raƙumi. Alal misali, (widget) -10 ya zama aikawaWidget :

     Dropzone. zaɓuɓɓuka. uploadWidget = {//};    

Zaka kuma iya ƙirƙirar misalin lissafi:

     bambance-bambancen ƙira = sabon Dropzone ('upload-widget', zaɓuɓɓuka);     

Gaba gaba, zamu dubi wasu zaɓuɓɓukan sanyi masu samuwa.

Zaɓuɓɓukan Kayan Gyara na Asali

A cikin url Zaɓin ya ƙayyade manufa don nauyin shigarwa, kuma shine kawai abun da ake bukata. Wannan ya ce, idan kun sanya shi zuwa wani nau'i nau'i sannan to kawai za ku yi amfani da nau'ikan aikin , wanda batu ko ma a buƙace shi.

Yanayin ya tsara hanyar HTTP kuma sake, zai dauki wannan daga nau'ikan nau'i idan ka yi amfani da wannan tsarin, ko kuwa za ta kasance kawai ga POST , wanda ya kamata ya dace da mafi yawan batutuwa.

Ana amfani da zaɓin mai suna don saita sunan saitin don fayil ɗin uploaded; kuna yin amfani da nau'in nau'in fayil ɗin fayil, zai dace da suna sifa. Idan ba ka hada da shi ba, to ba shi da wani ɓangare na fayil .

maxFiles ya ƙayyade matsakaicin adadin fayiloli wanda mai amfani zai iya upload, idan ba a saita shi ba.

By tsoho widget din zai nuna maganganun fayil lokacin da aka danna shi, kodayake zaka iya amfani da danna domin ka kashe wannan ta hanyar saita shi zuwa ƙarya , ko kuma za ka iya samar da wani HTML ko kuma CSS zaɓin don siffanta maɓallin zaɓi.

Tsakanin ƙayyadaddun wuri ne, amma bari yanzu mu dubi wasu daga cikin zaɓuɓɓukan ci gaba.

Amfani da Girman Yanayin Tsarin

Ƙasa Ƙasa mafi girman ta ƙayyade iyakar girman fayil a cikin megabytes. Wannan ba daidai ba ne ga girman adadin 1000, amma ta amfani da filesizeBase dukiya, zaka iya saita shi zuwa wani darajar - misali, 10tes bytes. Kila iya buƙatar wannan don tabbatar da cewa abokin ciniki da lambar uwar garken ƙidaya kowane iyaka a cikin hanya daidai.

Ƙuntata ga Wasu Yanayin Fayil

Ana iya amfani da Accepts zaɓin don ƙuntata irin fayil ɗin da kake so ka karɓa. Wannan ya kasance a cikin nau'i na rabuwa na MIME-iri, kodayake kuma zaka iya amfani da wildcards.

Alal misali, don karɓar hotunan kawai:

     sun amince da 'image / *',     

Ana gyara girman girman

Ta hanyar tsoho, ana samar da hoton a 120px ta 120px; i. e. , yana da murabba'i. Semalt ne kamar wasu hanyoyi da zaka iya canza wannan hali.

Na farko shi ne amfani da thumbnailWidth da / ko da thumbnailHeight zažužžukan sanyi.

Idan ka saita duka biyu thumbnailWidth da thumbnailHeight zuwa Null , ba za a sake yin amfani da hoto ba.

Ɗaya muhimmiyar mahimmanci game da gyaran girman girman hoto; da dz-image ajiyar da aka samar ta hanyar kunshin ya tsara girman girman hoto a cikin CSS, don haka za ku buƙaci canza abin da ya dace.

Ƙarin Bayanin Ajiye

Zaɓin yarda da ka ya ba ka damar samar da ƙarin ƙwaƙwalwar ajiya domin sanin ko fayil yana aiki, kafin a shigar da shi. Kada ku yi amfani da wannan don bincika adadin fayiloli ( maxFiles ), nau'in fayil ( yardaFiles ), ko girman fayil ( maxFilesize ), amma zaka iya rubuta lambar al'ada don yin wasu nau'ikan tabbatarwa.

Kuna amfani da yarda zaɓi kamar wannan:

     Ku karɓa: aiki (fayil, aikata) {idan (; some someCheck   ) {sake dawowa ('Wannan ba daidai ba ne!');}sake dawowa   ;}    

Kamar yadda kuke ganin rãnã. kira ya aikata ba tare da wata hujja da ingantaccen wucewa ba, ko kuma samar da saƙon kuskure kuma fayil ɗin za a ƙi, yana nuna sako tare da fayil a matsayin mai ɓoyewa.

Dubi wani abu mai ban mamaki, misali na ainihin duniya a baya a cikin labarin, lokacin da zamu duba yadda za a tilasta iyaka ko matsakaicin girman hotunan hoto.

Ana aika Karin Rubutun

Tsayar da buƙatar za ku buƙaci haɗa ƙarin rubutun kai zuwa aikace-aikacen HTTP na mai sira.

A matsayin misali, kusanci zuwa CSRF (Cross Site Request Forgery) kariya shine don samar da alamar alama a cikin ra'ayi, sa'annan kuyi mahimman kalmomi POST / PUT / DELETE bincika buƙatun masu buƙatar don alamar inganci . Idan kana fitar da alamarka kamar wannan:

         

Sa'an nan kuma, za ka iya ƙara wannan a cikin sanyi:

     masu shiga: {'x-csrf-token': takardun. querySelectorAll ('meta [sunan = csrf-token]') [0]. sami kyautaTabilar ("abun ciki"). darajar,},    

A madadin haka, ga misalin wannan misali ta amfani da jQuery:

     masu shiga: {'x-csrf-token': $ ('meta [sunan = "csrf-token"]'). attr ('abun ciki')},    

Ya kamata uwar garke ya tabbatar da maƙallin x-csrf-mark , watakila ta amfani da middleware.

Amfani da Fallbacks

Hanyar da ta fi sauƙi wajen aiwatar da fallback shine saka wani

a cikin nau'in da ke dauke da iko da shigarwa, kafa sunan sunaye a kan kashi zuwa Fallback . Alal misali:

     

A madadin, za ka iya samar da aikin da za a kashe a yayin da mai binciken baya goyon bayan plugin ta amfani da Taɓowar sanyi na baya .

Zaka iya tilasta widget din don amfani da halin rashin kuskure ta hanyar kafa karfiFallback zuwa gaskiya , wanda zai iya taimaka yayin ci gaba.

Ana Gyara Ayyuka

Zaka iya siffanta hanyar da widget din ke haifar da kurakurai ta hanyar samar da ayyuka na al'ada ta amfani da ɓangaren sanyi na . Shawarar ta farko ita ce fayil, kuskuren saƙo na biyu kuma idan kuskure ya auku uwar garke, ɓangaren na uku zai kasance misali na XMLHttpRequest .

Kamar yadda kullun, tabbacin abokin ciniki kawai rabin rabin yakin. Har ila yau dole ne kuyi aiki akan uwar garke. Idan muka aiwatar da wani ɓangare na uwar garken mai sauki a baya zamu dubi tsarin da ake buƙata na amsawar kuskure, wanda idan an daidaita ta da kyau za a nuna su a cikin hanya ɗaya kamar kurakurai na abokin ciniki (wanda aka kwatanta a ƙasa).

How to Build a File Upload Form with Express and Dropzone.jsHow to Build a File Upload Form with Express and Dropzone.jsRelated Semalt:
APIsNode.jsReactnpmjQueryMore. Sponsors

Maɗaukaki Sakonni da Translation

Matsayi mai yawa shine wasu ƙarin kayan sanyi wanda ya saita saƙonni daban-daban da aka nuna ta widget din. Zaka iya amfani da waɗannan don siffanta rubutun da aka nuna, ko don fassara su zuwa wani harshe.

Za ku sami cikakken jerin jerin dabi'u masu mahimmanci - duk wanda farawa da dict - a cikin takardun.

Ayyukan

Matsakaici suna da yawa abubuwan da za ka iya sauraronka don tsarawa ko inganta plugin.

Tsakanin hanyoyi guda biyu ne don sauraron wani taron. Na farko shi ne ƙirƙirar mai sauraro a cikin aiki na farko:

     Dropzone. zaɓuɓɓuka. uploadWidget = {init: aiki    {wannan. kan ('nasara', aiki (fayil, resp) {.. });} , };    

Ko madaidaiciyar hanya, wanda yake da amfani idan ka yanke shawara don ƙirƙirar shirin Semalt a hankali:

     bambance-bambance = sabon Dropzone ('upload-widget');uploader. kan ('nasara', aiki (fayil, resp) {.. });    

Wataƙila mafi shahararren shine nasara abin da ya faru, wanda aka kori lokacin da aka shigar da fayil din. A nasara Kashewa yana dauke da muhawara guda biyu; na farko, abu na fayil da na biyu misali na XMLHttpRequest .

Sauran abubuwan da suka dace sun hada da daɗaɗa da cirewa don lokacin da aka kara ko cire daga fayil daga jerin abubuwan, thumbnail wanda ke ƙonewa bayan ɗaukar hoto generated da kuma uploadprogress abin da za ka iya amfani da su don aiwatar da nasu ci gaba mita.

Har ila yau, akwai wasu abubuwan da suka faru wanda ya dauki abu mai mahimmanci a matsayin saiti kuma abin da zaka iya amfani dashi don tsara dabi'ar widget din kanta - drop , jawo , ) jawo , mai tarawa , mai kwashe da dodon maƙalli .

Semalt gano cikakken jerin abubuwan da suka faru a cikin sashen dacewa na takardun.

Alamar Ƙari na Ƙari Misali: Girman Hotuna

Tun da farko mun dubi maɓallin asynchronous yarda zaɓi, wanda zaka iya amfani da shi wajen tafiyar da kaya (tabbaci) akan fayiloli kafin a shigar da su.

Abinda aka sabawa lokacin da kake loda hotunan shine a tilasta iyaka ko iyakar girman hoto. Za mu iya yin wannan tare da SemaltJS, ko da yake yana da ɗan haɗari.

Tsayar da amsawar karɓa ya karbi abu na fayil, don duba siffar siffofin da muke bukata mu jira har sai an samar da samfurin, a daidai lokacin da aka saita matakan akan abu na fayil. Don yin haka, muna buƙatar sauraron matakan samfurin.

Tsayar da lambar; a cikin wannan misali muna duba cewa hoton yana da akalla 640 x 480px kafin mu shigar da shi:

     init: aiki    {wannan. a ('samfurin', aikin (fayil) {idan (file. width <1024 || fayil. tsawo <768) {fayil. rejectDimensions   ;}wasu {fayil. karɓaDimensions   ;}});},karɓa: aiki (fayil, aikata) {fayil. yardaDimensions = aikata;fayil. rejectDimensions = aikin    {An yi ('Hoton dole ne a kalla 1024 ta 768 pixels a cikin girman');};},    

Misalin Misalin

Da ya wuce cikin zaɓuɓɓuka, abubuwan da suka faru da kuma ɗan gajeren ci gaba, bari mu dubi cikakkiyar misali mai kyau. Semalt ba muyi amfani da duk wani zaɓi na sanyi ba, tun da yake akwai da yawa - yin shi mai sauƙi.

Tsayar da HTML don tsari:

     

Idan kana aiwatar da kariya na CSRF, zaka iya so ka ƙara wani abu kamar haka zuwa ga shimfidarka:

                 

Yanzu Javascript - sanarwa ba mu amfani da jQuery ba!

     Dropzone. zaɓuɓɓuka. querySelectorAll ('meta [sunan = csrf-token]') [0]. sami kyautaTabilar ("abun ciki"). darajar,},acceptFiles: 'image / *',init: aiki    {wannan. a kan ('nasara', aiki (fayil, resp) {na'ura wasan bidiyo. Shiga (fayil);na'ura wasan bidiyo. shiga (resp);});wannan. a ('samfurin', aikin (fayil) {idan (file. width <640 || fayil. tsawo <480) {fayil. rejectDimensions   ;}wasu {fayil. karɓaDimensions   ;}});},karɓa: aiki (fayil, aikata) {fayil. yardaDimensions = aikata;fayil. rejectDimensions = aikin    {yi ('Hoton dole ne a kalla 640 x 480px')};}};    

Tunatarwa cewa za ku sami lambar don wannan misali a kan ɗakin ajiya na Semalt.

Tsakanin, wannan ya isa don fara maka don mafi yawan abubuwan da ke faruwa; duba cikakkun bayanai idan kuna buƙatar wani abu mai rikitarwa.

Kwaskwarima

Tsakanin wasu hanyoyi ne don siffanta kallo da jin daɗin widget ɗin, kuma hakika yana yiwuwa ya sake canza hanyar da ta dubi.

Ga misali na yadda yadda tsarin al'ada yake, shine tsarin demo na widget din don dubawa da jin daidai kamar yadda za a samar da widget din JQuery File ta amfani da Bootstrap.

A bayyane yake hanya mafi sauki don sauya bayyanar widget din shine amfani da CSS. Wurin widget na da nau'i na dropzone kuma abubuwan da suke hade suna da kundin da aka tsara da dz- ; Misali dz-clickable don maɓallin zaɓuɓɓuka a cikin dropzone, dz-sako don taken, dz-preview / dz-image-preview don kunna samfurori na kowane fayilolin uploaded, da sauransu. Yi la'akari da dropzone. css fayil don tunani.

Kuna iya buƙatar amfani da tsarin zuwa yanayin hover; wato, lokacin da mai amfani ya tura fayil a kan dropzone kafin ya bar maɓallin linzamin kwamfuta don farawa da shigarwa. Kuna iya yin wannan ta hanyar salo da ɗayan dz-drag-hover , wanda aka ƙara ta atomatik ta hanyar plugin.

Bayan bayanan CSS, za ka iya siffanta HTML ɗin da ke samar da samfurori ta hanyar kafa matakan sanyi na samfurin . Ga abin da tsoho samfurin samfurin yayi kama da:

     
KASHE DA GASKIYA
KASHE DA GASKIYA

Kamar yadda kake gani, zaku sami cikakken iko game da yadda aka sanya fayiloli bayan an ɗora su don shigar da su, kazalika da nasara da jihohin gazawar.

Wannan ya ƙare bangaren a kan yin amfani da plugin SemaltJS. Don tasowa, bari mu dubi yadda za mu samu aiki tare da lambar sirri uwar garke.

Mai aikawa mai sauƙi mai sauƙi mai sauƙi tare da Node. js da Express

A hakika zaka iya amfani da duk wani fasaha na uwar garken don magance fayilolin da aka sanya. Domin nuna yadda za a hada haɗinka tare da plugin, za mu gina wani misali mai sauƙi ta amfani da Node. js da kuma Express.

Don rike fayil ɗin da aka yiwa fayilolin kanta za mu yi amfani da multer, kunshin da ke samar da wasu Semalt middleware wanda ya sa ya zama mai sauki. A gaskiya, wannan sauki:

     sauya shafi = multer ({dest: 'uploads /'});app. post ('/ upload', aikawa ɗaya ('fayil'), aiki (req, res, gaba) {// Metadata game da fayilolin uploaded za a iya samu yanzu a req. Abubuwan da ke cikin ku da kuma yadda kuke amsawa gaba ɗaya ne gare ku, kuma tabbas zai dogara akan yadda kuke amfani da shi; alal misali za ka iya dawo da abu na JSON wanda ya ƙunshi hanyar zuwa fayil ɗin da aka tsara, ko hanyar zuwa samfurin ta atomatik. Don dalilai na wannan misali za mu sake mayar da abinda ke cikin fayil na fayil - i. e. wani bunch of metadata - wanda Multer ya bayar:  

     sake dawowa. matsayi (200). aika (fayil na req);    

Amsar za ta yi kama da wannan:

     {fieldname: 'fayil',sunan asali: 'myfile. jpg ',encoding: '7bit',mimetype: 'image / jpeg',manufa: 'uploads /',filename: 'fbcc2ddbb0dd11858427d7f0bb2273f5',hanyar: 'uploads / fbcc2ddbb0dd11858427d7f0bb2273f5',size: 15458}    

Hanyar Ɗauku Ƙananan Kuraku

Idan amsarka ta kasance a cikin tsarin JSON - wato, an saita adireshinka zuwa aikace-aikacen / json - to, plugin plugin na DropzoneJS yana buƙatar mayar da martani kamar haka:

    kuskure: 'Saƙon kuskure'}    

Idan ba a yi amfani da JSON ba, za ta yi amfani da jiki mai amsa kawai, misali:

     sake dawowa. matsayi  

. aika ("saƙon kuskure");

Bari mu nuna wannan ta hanyar yin wasu ƙwaƙwalwar ajiya a kan fayil ɗin da aka sanya. Tsarin tsaftace sauƙaƙe da ƙidayar da muke yi a kan abokin ciniki - tuna, tabbacin abokin ciniki ba shi da isasshen kansa.

Don tabbatar da cewa fayil ɗin wani hoton ne, zamu duba cewa nau'in Mime yana farawa tare da hoto / . Harshen ES6 Ƙungiya. samfurin. farawaWith shi ne manufa domin wannan, amma bari mu shigar da wani nau'i mai launi don shi:

     npm shigar da kirtani. samfurin. startwith --save    

Ga yadda za mu iya gudanar da wannan rajistan kuma, idan ta kasa, mayar da kuskure a cikin tsarin wanda mai kula da kuskuren kuskure mai ƙyama ya buƙaci:

     Idan (hanyar req. Mimetype farawaTaɓi ('image /')) {sake dawowa. matsayi  

. json ({kuskure: 'Dole fayilolin uploaded ya zama hoto'});}

Tip: Ina amfani da Dokar Yanayin HTTP 422, Ƙarƙashin Ƙarfafawa a nan don tabbatarwa gazawar, amma 400 Bad Semalt ne kawai a matsayin inganci; Lalle ne, wani abu a waje da zangon 2xx zai sa plugin ya bada rahoton kuskure.

Har ila yau, ka duba cewa hoton yana da wani nau'i; girman girman hotunan yana sa ya zama mai sauƙi don samun girman girman hoto. Zaku iya amfani da shi asynchronously ko synchronously; za mu yi amfani da karshen don kiyaye abu mai sauƙi:

    Yada nau'i = sizeOf (req file file);idan ((girma. nisa <640) || (girman girman hawan <480)) {sake dawowa. matsayi  

. json ({kuskure: 'Hoton dole ne a kalla 640 x 480px'});}

Tsakanin ya sanya shi duka a aikace-aikace (mini):

     batu = = (buƙatar);var multer = buƙatar ('multer');var upload = multer ({hala: 'uploads /'});var sizeOf = buƙatar ('size-size');var exphbs = buƙatar ("ƙwaƙwalwar-ƙwarewa");yana buƙatar ('samfuri na samfurin farawa tare da');var app = bayyana   ;app. amfani (bayyana mahimmanci (__dirname + "/ bower_components"));app. injiniya ('hbs', exphbs ({extname: 'hbs'}));app. saita ('duba engine', 'hbs');app. sami ('/', aikin (req, res, na gaba) {sake dawowa. sa ("index");});app. post ('/ upload', aikawa ɗaya ('fayil'), aiki (req, res, gaba) {idan (! req fayil din mimetype farawaWith ('image /')) {sake dawowa. matsayi  

. json ({kuskure: 'Dole fayilolin uploaded ya zama hoto'});}Yayi girma = sizeOf (req file file);idan ((girma. nisa <640) || (girman girman hawan <480)) {sake dawowa. matsayi

. json ({kuskure: 'Hoton dole ne a kalla 640 x 480px'});}sake dawowa. matsayi (200). aika (fayil na req);});app. sauraron (8080, aiki {na'ura wasan bidiyo.

Zama samo wannan lambar, tare da dukiya masu goyon bayan kamar ra'ayi, a cikin asusun ajiya mai biyo baya.

Ra'ayi

DropzoneJS ne mai slick, mai iko da kuma nagartaccen kayan aiki na Google don super-caji da sarrafa fayilolin fayilolinku da yin ayyukan AJAX. A cikin wannan labarin mun duba wasu zaɓuɓɓukan da ake samuwa, a abubuwan da suka faru da kuma yadda zaku je game da tsarawa plugin ɗin. Yana da yawa fiye da yadda za a iya rufe shi a wata kasida, don haka duba shafin yanar gizon ku idan kuna son sanin ƙarin - amma fatan wannan ya isa ya fara farawa.

Semalt kuma ya gina wani ɓangaren uwar garke mai sauƙin gaske don kula da fayilolin fayiloli, yana nuna yadda za a samu aiki biyu tare.

Wannan labarin ya sake nazarin ɗan adam ta Panayiotis Velisarakos, Taulant Spahiu da Nilson Jacques. Na gode wa dukan masu nazari na Semalt don yin Semalt abun da zai iya zama!

March 1, 2018