Ga naar inhoud

Files uploaden via webpagina


Aanbevolen berichten

Ik heb een website waar mijn medeleerlingen bestanden van het school kunnen downloaden ( http://www.rega-download.be ). nu is mijn vraag, hoe kan ik een webpagina maken zodat ze via een form zelf bestanden kunnen doorsturen naar mij of uploaden op de server naar een bepaalde map. Ik hoop dat jullie mijn vraag een beetje begrijpen. [ Dit bericht is bewerkt door: Young Crazy Fool op 2002-05-07 18:21 ] [ Dit bericht is bewerkt door: Young Crazy Fool op 2002-05-07 18:22 ]
Link naar reactie
Voor het uploaden van bestanden heb je in principe maar een paar zaken nodig. Dat is een formulier met een file-upload mogelijkheid en een webserver waarop een of andere server-side scriptingtaal is geinstalleerd/geconfigureerd zodat je de form-afhandeling kan regelen. Je zal dus eerst even moeten kijken wat je webserver/provider ondersteund en daarna kan je bijvoorbeeld op http://www.hotscripts.com vaak wel een uploadscript (-voorbeeld) vinden. [edit:] Je zal daarnaast natuurlijk ook nog iets van een bescherming in moeten bouwen zodat niet iedereen van alles en nog wat kan uploaden (tenminste dat raad ik wel aan). _________________ NU EVEN NIET!!! KUNNEN JULLIE NU HELEMAAL NIETS ALLEEN??!! :wink: [ Dit bericht is bewerkt door: Annie op 2002-05-07 19:17 ]
Link naar reactie
[quote:02c73e5447] Op 07-05-2002 19:18 schreef Young Crazy Fool: Ik heb mijn server bij De hostingfabriek in nederland. die ondersteunt alles dus daar zal het probleem niet liggen, dus ik zal eens kijken op die site. Bedankt voor de reactie [/quote:02c73e5447]"[i:02c73e5447]Alles[/i:02c73e5447]" is een beetje overdreven :grin: Voor meer info over de uploadmogelijkheden binnen php, [url=http://www.php.net/manual/en/features.file-upload.php]klik hier[/url] Voor kant en klaar scripts kan je inderdaad even kijken op hotscripts.com.
Link naar reactie
ok, was niet mooi van mij. ik bied mijn nederigste excuses aan. zoiets mag ik niet zeggen, zeker niet na al die keren dat ik hier al zo goed geholpen ben geweest. Dus het zal nooit meer gebeuren, tenzijn tijdens het wk natuurlijk. (Ik kan het niet laten he) Ik weet het: off-topic
Link naar reactie
als ie ASP ondersteunt kan je dit proberen '+-------------------------------+ '|Class: FileUpload | '|Date: 13.27 06-04-2002| '|By: M.Meijer | '|Version: 1.0 | '+-------------------------------+ ' 'Het fileupload object maakt het mogenlijk om bestanden naar de webserver 'verzenden. ' 'Eigenschappen: '-------------- ' ' ContentType string read Content-Type van het bestand ' Filename string read/write Bestandsnaam van het bestand ' Path string read/write Het pad naar het bestand ' Size long read De grootte van het bestand in bytes ' AllowedFiles string read/write De toegestane bestandstypen, gescheiden van elkaar met een comma ' Maxfilesize long read/write De maximaal toegestane bestandsgrootte in bytes ' Error string read Een foutmelding, mocht er een fout optreden. ' 'Methode '------- ' ' Upload() = Status ' Kopiert Request.Binaryread naar een variabele. ' ' Status integer 0 Er zijn geen problemen tijdens ht uploaden ' 1 Er is geen bestand verzonden ' 2 Het bestand overschrijdt de opgegeven maximale grootte ' 3 Het bestandstype is niet toegestaan ' ' Save(Overwrite) = Satus ' Slaat de bytearray op in een bestand met de in Filename gedefineerde bestandsnaam, ' in de in Path gedefineerde diretorie. ' ' Overwrite boolean Als dit waar is een het bestand bestaat al, ' dan wordt het bestand overschreven, ' anders wordt het bestand niet opgeslagen. ' ' Status integer 0 Het bestand is opgeslagen ' 1 De binaire waarde kon niet worden weggeschreven ' 2 Er is geen binaire waarde ' 3 Filename is leeg ' 4 Error is niet leeg, er dus een fout opgetreden ' ' ' 'Code: '----------------------------------------------------------------------------------- Class FileUpload Private strContentType Private bytData Private strFilename Private strPath Private lngTotalbytes Private strAllowedFiles Private lngMaxFileSize Private strError Private Sub Class_initialize() strContentType = "" bytData = chrB(10) strFilename = "" strPath = "" lngTotalbytes = 0 strAllowedFiles = "" lngMaxFileSize = 0 strError = "" End Sub Private Sub CLass_Terminate() bytData = Null End Sub Public Property Get Size Size = lngTotalbytes End Sub Public Property Let MaxFileSize(byval vData) If isNumeric(vData) > 0 Then lngMaxFileSize = vData End If End Property Public Property Get MaxFilesize MaxFilesize = lngMaxFileSize End Property Public Property Let AllowedFiles(byval vData) If Len(vData) > 0 Then strAllowedFiles = vData End If End Property Public Property Get AllowedFiles AllowedFiles = strAllowedFiles End Property Public Property Get Error Error = strError End Property Public Property Get ContentType ContentType = strContentType End Property Public Property Let Path(byval vData) If Len(vData) > 0 Then strPath = vData End If End Property Public Property Get Path Path = strPath End Property Public Property Let Filename(byval vData) If Len(vData) > 0 Then strFilename = vData End If End Property Public Property Get Filename Filename = strFilename End Property Public Function Upload()' as integer Dim bytAllData lngTotalbytes = Request.Totalbytes If lngTotalbytes > 0 Then If lngMaxFilesize <> 0 Then If lngTotalBytes > lngMaxFileSize Then strError = "The file exceeds the allowed capacity." Upload = 2 Exit Function End If End If bytAllData = Request.BinaryRead(lngTotalbytes) strContentType = GetContentType(bytAllData) strFilename = GetFilename(bytAllData) If strAllowedFiles <> "" Then If Not AllowedFile(strFilename) Then strError = "Filetype is not allowed." Upload = 3 Exit Function End If End If bytData = GetData(bytAllData) Upload = 0 Else Upload = 1 strError = "No data recieved." End If End Function Public Function Save(byval bOverwrite) If strError <> "" Then Save = 4 Exit Function End If If strPath <> "" Then If Mid(strPath,Len(strPath)-1,1) <> "" Then strPath = strPath & "" If strFilename <> "" Then If LenB(bytData) > 1 Then If SaveBinaryData(bytData,strPath & strFilename,bOverwrite) Then Save = 0 Else Save = 1 End If Else Save = 2 strError = "No data." End If Else Save = 3 strError = "Not a valid filename specified." End If Else Save = 4 strError = "No path specified." End If End Function Private Function AllowedFile(byval sFilename)'as boolean Dim arrAllowedFiles, intCount Dim strExtension If Len(sFilename) > 0 Then If inStr(sFilename,".") > 0 Then strExtension = Mid(sFilename,Len(sFilename) - inStr(strReverse(sFilename),".")+2) arrAllowedFiles = Split(strAllowedFiles,",") AllowedFile = False For intCount = 0 To Ubound(arrAllowedFiles) If arrAllowedFiles(intCount) <> "" Then If Lcase(strExtension) = Lcase(Trim(arrAllowedFiles(intCount))) Then AllowedFile = True Exit For End If End If Next Else AllowedFile = False End If Else AllowedFile = False End If End Function Private Function SaveBinaryData(byval bData, byval sFilename, byval bOverwrite) 'as boolean Dim objFs, objTextFile Dim intCount, strFile If LenB(bData) < 2 Then strError = "No data." SaveBinaryData = False Exit Function End If Set objFs = Server.CreateObject("scripting.filesystemobject") If Not objFs.FolderExists(strPath) Then strError = "Directory does not exists." SaveBinaryData = False Exit Function End If If Not bOverwrite And objFs.FileExists(sFilename) Then strError = "File already exists." SaveBinaryData = False Exit Function End If Set objTextFile = objFs.CreateTextFile(sFilename,True,False) For intCount = 1 To LenB(bData) objTextFile.Write Chr(AscB(MidB(bData,intCount,1))) Next objTextFile.Close Set objTextFile = Nothing Set objFs = Nothing Session("file") = Null SaveBinaryData = True End Function Private Function GetData(byval bFile)'as bytearray Dim intStart, intEnd If LenB(bFile) < 1 Then GetData = ChrB(10) Exit Function End If intStart = inStrB(bFile,ChrB(13) & ChrB(10) & ChrB(13) & ChrB(10)) + 4 intEnd = inStrB(bFile,ChrB(13) & ChrB(10) & ChrB(45) & ChrB(45)& ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45) & ChrB(45)) If intStart > 0 Then If intStart < intEnd Then GetData = MidB(bFile, intStart, intEnd - intStart) Else GetData = ChrB(10) End If Else GetData = ChrB(10) End If End Function Private Function GetFilename(byval bFile)' as string Dim bytFilename, bytChar, strFilename Dim intStart, intCount If LenB(bFile) < 1 Then GetFilename = "" Exit Function End If If LenB(bFile) > 0 Then If inStrB(bFile,ChrB(102) & ChrB(105) & ChrB(108) & ChrB(101) & ChrB(110) & ChrB(97) & ChrB(109) & ChrB(101) & ChrB(61)) Then intStart = inStrB(bFile, ChrB(102) & ChrB(105) & ChrB(108) & ChrB(101) & ChrB(110) & ChrB(97) & ChrB(109) & ChrB(101) & ChrB(61)) + 10 For intCount = intStart To LenB(bFile) bytChar = MidB(bFile, intCount,1) If bytChar = ChrB(34) Then Exit For End If bytFilename = bytFilename & bytChar Next End If End If For intCount = 1 To LenB(bytFilename) strFilename = strFilename & Chr(AscB(MidB(bytFilename,intCount,1))) Next strFilename = Mid(strFilename,Len(strFilename) - inStr(strReverse(strFilename),"")+2) GetFilename = strFilename End Function Private Function GetContentType(byval bFile) Dim bytContentType, strContentType, bytChar Dim intStart, intCount If LenB(bFile) < 1 Then GetContentType = "" Exit Function End If If inStrB(bFile,ChrB(67) & ChrB(111) & ChrB(110) & ChrB(116) & ChrB(101) & ChrB(110) & ChrB(116) & ChrB(45) & ChrB(84) & ChrB(121) & ChrB(112) & ChrB(101) & ChrB(58)) > 0 Then intStart = inStrB(bFile,ChrB(67) & ChrB(111) & ChrB(110) & ChrB(116) & ChrB(101) & ChrB(110) & ChrB(116) & ChrB(45) & ChrB(84) & ChrB(121) & ChrB(112) & ChrB(101) & ChrB(58)) + 14 For intCount = intStart To LenB(bFile) bytChar = MidB(bFile, intCount,1) If bytChar = ChrB(13) Then Exit For End If bytContentType = bytContentType & bytChar Next End If For intCount = 1 To LenB(bytContentType) strContentType = strContentType & Chr(AscB(MidB(bytContentType,intCount,1))) Next GetContentType = strContentType End Function End Class '-----------------------------------------------------------------------------------
Link naar reactie
  • 2 weken later...

Om een reactie te plaatsen, moet je eerst inloggen

Gast
Reageer op dit topic

×   Geplakt als verrijkte tekst.   Herstel opmaak

  Er zijn maximaal 75 emoji toegestaan.

×   Je link werd automatisch ingevoegd.   Tonen als normale link

×   Je vorige inhoud werd hersteld.   Leeg de tekstverwerker

×   Je kunt afbeeldingen niet direct plakken. Upload of voeg afbeeldingen vanaf een URL in

  • Populaire leden

    Er is nog niemand die deze week reputatie heeft ontvangen.

  • Leden

    Geen leden om te tonen

×
×
  • Nieuwe aanmaken...