PDA

View Full Version : Creating a File Upload page


Scott
09-06-2005, 04:08 AM
Here is a workable (though not quite finished) user control for file uploads that you nay be able to adapt for your purposes.

[quote]<%@ControlLanguage='VB'ClassName='FileUpload'%>

<scriptlanguage='vb'runat='server'>

'------------------------------------------------
subPage_Load(senderasobject,easeventargs)

ifnotIsPostBackthenspan1.InnerHtml=''

endsub


'------------------------------------------------
subSubmitButton_Click(senderasobject,easeventargs)

'Grabthefilenamefromitsfullyqualifiedpathatclient
DimstrFileNameasstring=File1.PostedFile.FileName
'uploadpathandfile
dimUploadFileasstring=Server.MapPath('')&'\'&'DUDocs\'&_
System.IO.Path.GetFileName(strFileName)

''*****NEEDCODETOCHECKWHETHERFILEEXISTSANDPROMPTFO ROVERWRITE
try
File1.PostedFile.SaveAs(UploadFile)
Span1.InnerHtml='UploadSuccessful!'
catchexasexception
Span1.InnerHtml='<spanstyle='color:red;'>Thefilecouldnotbeuploaded</span>'
endtry

endsub

</script>

<html>
<head><title>FileUpload</title></head>
[b]

Selectafiletoupload:[b]
<inputtype='file'id='File1'runat='server'style='wid th:100%;'>
<p/>
<inputtype='submit'id='Submit1'runat='server'value= 'UploadFile'OnServerClick='SubmitButton_Click'>
<p/>
<spanid='Span1'runat='server'/>

</body>
</html></CODE>

The control is based on this Microsoft article:
msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspnet-fileupload.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspnet-fileupload.asp)

Post Edited (Scott) : 9/6/2005 5:11:00 PM GMT

bruce
09-06-2005, 06:28 AM
if you are not familiar with .NET, heres an ASP example.

http://kb.discountasp.net/article.aspx?id=10058

Bruce

DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)

TVaughan
09-06-2005, 11:53 AM
Hi
I am in need of creating a file upload page for clients to upload a few pictures to be worked on. Is there a cgi (or any) script or document explaning the steps? (Or at least the correct path needed from the server side?) Thanks

pafro
09-07-2005, 04:32 AM
For PHP try

http://www.phpfreaks.com/quickcode/Simple-File-Uploader/272.php
http://www.phpfreaks.com/quickcode/File-Uploader/152.php

Both are at PHPFREAKS - a decent source of information for beginners.

TVaughan
09-07-2005, 11:16 AM
Thanks!