hi
can anyone give me an asp code for uploading images on a server.
Have been trying the code on free asp upload but am getting a message that the directory in whicj i want to upload does not exist where as it do exists.
When i remove read only properties from the directory then it too mauch time and the page does not even appear.
Recommended Answers
Jump to Post0 then 'Destination is specified. check its validity. ''''' fDestination = clng(fDestination) ''''' if fDestination>=0 and fDestination0 then if len(DestinationPath) > 0 then Form.Files.Save DestinationPath response.redirect("Videouploaded1.asp") response.write "
Files (" & Form.TotalBytes \1024 & "kB) was saved to " & DestinationPath & " folder." else response.write "
Bad destination path." …
All 2 Replies
radharadha 0 Newbie Poster
0 then 'Destination is specified. check its validity. ''''' fDestination = clng(fDestination) ''''' if fDestination>=0 and fDestination0 then if len(DestinationPath) > 0 then Form.Files.Save DestinationPath response.redirect("Videouploaded1.asp") response.write "
Files (" & Form.TotalBytes \1024 & "kB) was saved to " & DestinationPath & " folder." else response.write "
Bad destination path." end ifElseIf Form.State > 10 then Const fsSizeLimit = &HD Select case Form.State case fsSizeLimit: response.write "
Source form size (" & Form.TotalBytes & "B) exceeds form limit (" & Form.SizeLimit & "B)
" case else response.write "
Some form error.
" end SelectEnd If'Form.State = 0 then%> Select VideoName(Select) File 1 :
Video Description :
//Expand form with a new File fields if needed.var nfiles = 3;function Expand(){ nfiles++ var adh = '
File '+nfiles+' : '; files.insertAdjacentHTML('BeforeEnd',adh); return false;}This is one of my page that i used for Image uploading to server..if u want more details u contact me on the Mail : radha_992@yahoo.co.in
radharadha 0 Newbie Poster
This is one of my page that i used for Image uploading to server..if u want more details u contact me on the Mail : [EMAIL SNIPPED]
<%
'Stores files to the clients specified destination folder
'Client can choose folder from a dropdown
'Remember that ther is NO good idea to let clients store files in ANY folder!
Dim DestinationsToChoose, cDest
'DestinationsToChoose = Array("c:\upload", "d:\inetpub\data1", "f:\store")
DestinationsToChoose = Server.MapPath("Images/")
'Create upload form
'Using Huge-ASP file upload
'Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm")
'Using Pure-ASP file upload
Dim Form: Set Form = New ASPForm %><!--#INCLUDE FILE="_upload.asp"--><%
'Server.ScriptTimeout = 2000
Server.ScriptTimeout = 3000
Form.SizeLimit = &HA00000
If Form.State = 0 Then 'Completted
Dim DestinationPath, fDestination
dim videoname,VName,v
videoname=Form("video")
VName=Form("T1")
v="Images/" & VName
'response.write(vname)
dim D1
D1=Form("txtFrom")
dim rsCheck
set rsCheck=mycon.execute("select * from CategoryDetails where Id="& videoname &"")
if not rsCheck.eof then
dim video
video="Images/" & rsCheck(2) & ".MP4.2"
mycon.execute("update CategoryDetails Set Video1='"& v &"',D1='"& D1 &"' where Id="& videoname &"")
else
response.redirect("notAssigned1.asp")
end if
rsCheck.close
'read destination index
'''''fDestination = Form("fDestination")
'''''if len(fDestination)>0 then
'Destination is specified. check its validity.
''''' fDestination = clng(fDestination)
''''' if fDestination>=0 and fDestination<=ubound(DestinationsToChoose) then
'''''DestinationPath = DestinationsToChoose(fDestination)
DestinationPath = DestinationsToChoose
''''' end if
''''' end if'if len(fDestination)>0 then
if len(DestinationPath) > 0 then
Form.Files.Save DestinationPath
response.redirect("Videouploaded1.asp")
response.write "<br><Font Color=green>Files (" & Form.TotalBytes \1024 & "kB) was saved to " & DestinationPath & " folder.</Font>"
else
response.write "<br><Font Color=red>Bad destination path.</Font>"
end if
ElseIf Form.State > 10 then
Const fsSizeLimit = &HD
Select case Form.State
case fsSizeLimit: response.write "<br><Font Color=red>Source form size (" & Form.TotalBytes & "B) exceeds form limit (" & Form.SizeLimit & "B)</Font><br>"
case else response.write "<br><Font Color=red>Some form error.</Font><br>"
end Select
End If'Form.State = 0 then
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//<HTML><HEAD>
<TITLE>ASP huge file upload - upload to a specified destination.</TITLE>
<STYLE TYPE="text/css"><!--TD {font-family:Arial,Helvetica,sans-serif }TH {font-family:Arial,Helvetica,sans-serif }TABLE {font-size:10pt;font-family:Arial,Helvetica,sans-serif }--></STYLE>
<meta name="robots" content="noindex,nofollow">
</HEAD>
<BODY BGColor=white>
<Div style=width:600>
<TABLE align=center cellSpacing=0 cellPadding=0 width="40%" border=0>
<TR>
<TD> </TD></TR></TABLE>
<TABLE align=center cellSpacing=2 cellPadding=1 width="40%" border=0>
<TR>
<TD colSpan=2>
<P>
<br>Upload timeout is <%=Server.ScriptTimeout%>s
<br>Form size limit is <%=Form.SizeLimit \ 1024 %>kB
</P>
</TD></TR></TABLE>
<TABLE align=center cellSpacing=1 cellPadding=8 bordercolor=silver bgcolor=GAINSBORO width="70%" border=1>
<form method="POST" ENCTYPE="multipart/form-data" name=f onSubmit="return upload()">
<tr><td>
</td><td>
<!--
<Select Name=fDestination>
-->
<%
'Dim lDestinationsToChoose
'For lDestinationsToChoose=0 to ubound(DestinationsToChoose)
' response.write "<OPTION VALUE=" & lDestinationsToChoose & ">" & DestinationsToChoose(lDestinationsToChoose)
'next
%>
<!--
</Select>
-->
</td></tr>
<tr><td>
Select VideoName
<select name=video><option value=(Select)>(Select)
<%
dim rsFeed
set rsFeed=mycon.execute("select * from CategoryDetails")
while not rsfeed.eof
response.write("<option value="& rsFeed(0) &">"& rsFeed(2) &"")
rsFeed.movenext
wend
%>
</select>
</td></tr>
<tr><td ColSpan=2>
<Div ID=files>
File 1 : <input type="file" name="File1" style="font-size: xx-small; height:20; width:250; border-width:1px"><input Name=SubmitButton Value="Upload Video >>" Type=submit style="font-size: xx-small; height:20; width:100; border-width:1px"><br>
<input type=hidden name=T1>
<br><br>
Video Description : <br><br>
<textarea rows=15 cols=45 name=txtFrom></textarea>
<br>
<br>
</Div>
<!--
<Input Type=Button Value="Add a file" OnClick=return(Expand())
Style="border=0;background=yellow;cursor:hand"><br>
-->
</td></tr>
<tr><td >
<!--
<input Value="Submit" Type=submit style="font-size: xx-small; height:20; width:100; border-width:1px"><br>
-->
</td></tr>
</form></Table>
</form>
<Script>
//Expand form with a new File fields if needed.
var nfiles = 3;
function Expand(){
nfiles++
var adh = '<BR> File '+nfiles+' : <input type="file" name="File'+nfiles+'">';
files.insertAdjacentHTML('BeforeEnd',adh);
return false;
}
</Script>
</td>
</tr>
</table>
</td>
</tr>
</table>
Edited by TrustyTony because: fixed formatting
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.