I am using ASPSmartUpload to load photos.
The user has to click twice on the "submit" button
before the photo(image file) is uploaded. After the
first click ..it seems to be doing some thing but one
actually needs to click again before the file is uploaded.
Here is the process:
There is a default photo. So, when the user actually
uploads his photo, first I delete the default file
then I take the first part of the uploaded file name
and rename(movefile) it to his username with the file
extension unchanged.
Please find below the form and the ASP code.
Could anybody tell me why I need to click a second
time to upload a file.
Thanks.
-----------------form---------------------------------------
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="snapSmart.asp" id=pictureForm name=pictureForm onsubmit="return checkPictureForm();">
<table border=0 align=center><tr><td valign=middle><INPUT TYPE=FILE SIZE=60 NAME="file1"></td></tr>
<tr><td align=center><INPUT TYPE=SUBMIT VALUE="submit" id=SUBMIT1 name=SUBMIT1>
</td></tr></table>
</FORM>
------------------code-----------------------------------
dim upload, File, fileExt
dim UploadPath, Count
dim conn, rs, objFSO
Dim start_time, end_time, str_filename, lng_size
UploadPath = server.MapPath("."
& "\common\"
start_time = now()
Set Upload = Server.CreateObject("aspSmartUpload.SmartUpload"
Upload.Upload
For each file In Upload.Files
str_filename = file.filename
lng_size = file.Size
fileExt = Mid(str_filename, InStrRev(str_filename, "."
+ 1)
If not file.IsMissing Then
if fileExt="jpg" or fileExt="gif" then
if lng_size < 50000 then
file.SaveAs(UploadPath & file.FileName)
end_time = now()
Response.Write "Your picture <b>"& File.FileName &"</b> has been uploaded successfully. <BR>"
set objFSO = Server.CreateObject("Scripting.FileSystemObject"
objFSO.DeleteFile UploadPath & session("Uname"
&"."& fileExt
objFSO.movefile UploadPath & str_filename, UploadPath & session("Uname"
&"."& fileExt
set objFSO = nothing
set conn = Server.CreateObject("adodb.Connection"
conn.Open Application("strConn"
set rs = Server.CreateObject("adodb.Recordset"
rs.Open "select * from QProfile where uname='" & session("Uname"
& "'",conn,1,3
rs("Snap_FExt"
= "." & fileExt
rs.Update
rs.Close
set rs = nothing
conn.Close
Response.redirect "Mypage.asp?uname="& session("Uname"
else
Response.Write "Image size should be less then equal to 50KB. <BR>"
end if
else
Response.Write "Image format should be either JPG or GIF. <BR>"
end if
end if
next
The user has to click twice on the "submit" button
before the photo(image file) is uploaded. After the
first click ..it seems to be doing some thing but one
actually needs to click again before the file is uploaded.
Here is the process:
There is a default photo. So, when the user actually
uploads his photo, first I delete the default file
then I take the first part of the uploaded file name
and rename(movefile) it to his username with the file
extension unchanged.
Please find below the form and the ASP code.
Could anybody tell me why I need to click a second
time to upload a file.
Thanks.
-----------------form---------------------------------------
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="snapSmart.asp" id=pictureForm name=pictureForm onsubmit="return checkPictureForm();">
<table border=0 align=center><tr><td valign=middle><INPUT TYPE=FILE SIZE=60 NAME="file1"></td></tr>
<tr><td align=center><INPUT TYPE=SUBMIT VALUE="submit" id=SUBMIT1 name=SUBMIT1>
</td></tr></table>
</FORM>
------------------code-----------------------------------
dim upload, File, fileExt
dim UploadPath, Count
dim conn, rs, objFSO
Dim start_time, end_time, str_filename, lng_size
UploadPath = server.MapPath("."
start_time = now()
Set Upload = Server.CreateObject("aspSmartUpload.SmartUpload"
Upload.Upload
For each file In Upload.Files
str_filename = file.filename
lng_size = file.Size
fileExt = Mid(str_filename, InStrRev(str_filename, "."
If not file.IsMissing Then
if fileExt="jpg" or fileExt="gif" then
if lng_size < 50000 then
file.SaveAs(UploadPath & file.FileName)
end_time = now()
Response.Write "Your picture <b>"& File.FileName &"</b> has been uploaded successfully. <BR>"
set objFSO = Server.CreateObject("Scripting.FileSystemObject"
objFSO.DeleteFile UploadPath & session("Uname"
objFSO.movefile UploadPath & str_filename, UploadPath & session("Uname"
set objFSO = nothing
set conn = Server.CreateObject("adodb.Connection"
conn.Open Application("strConn"
set rs = Server.CreateObject("adodb.Recordset"
rs.Open "select * from QProfile where uname='" & session("Uname"
rs("Snap_FExt"
rs.Update
rs.Close
set rs = nothing
conn.Close
Response.redirect "Mypage.asp?uname="& session("Uname"
else
Response.Write "Image size should be less then equal to 50KB. <BR>"
end if
else
Response.Write "Image format should be either JPG or GIF. <BR>"
end if
end if
next