Upload - Shadow Uploader - Code just hangs and nothing gets uploaded
Discuss Shadow Uploader - Code just hangs and nothing gets uploaded in the ASP Development forum on ASP Free. Shadow Uploader - Code just hangs and nothing gets uploaded ASP Development forum discussing ASP related topics including coding practices, ASP tips, and more. Active Server Pages (ASP) enables you to empower your HTML pages dynamically with robust scripting options.
ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Receive the tools necessary to be the rock star of your field. Our 12-month program teaches you the evolving world of multi-channel marketing as well as the complex issues and opportunities found in the industry.
Web development can be a daunting task, even for specialists. There is a lot of information to absorb and a lot of technologies to learn in order to manage a superior website. When trying to learn the ropes, developers need a reliable source to introduce new ideas that can be easily implemented. When working on large projects, even web veterans may run into a technology or an aspect of a technology that they are unfamiliar with.
Posts: 155
Time spent in forums: 1 Day 2 h 58 m 13 sec
Reputation Power: 6
Upload - Shadow Uploader - Code just hangs and nothing gets uploaded
Hi, I am trying out the ShadowUpload script for the first time for uploading photos etc. I place the ShadowUpload script, upolad page that goes with the script in the wwwroot and then made a folder with full read/write permissions enable called uploads. When I tried to upload a large picture, it gives me the expected error
Quote:
sample code using this upload script: Code: found 1 files...
file name: CIMG6060.JPG
file type: image/pjpeg
file size: 431914
image width: 2000
image height: 1500
image to big, not saving!
--------------------------------------------------------------------------------
thank you,
However when the file size of the jpg is correct and below 200 x 200 pixels, the code just hangs and nothing gets uploaded.
the sample test upload form I am using is
Code:
<!-- #include file="ShadowUploader.asp" -->
<%
Dim objUpload
If Request("action")="1" Then
Set objUpload=New ShadowUpload
If objUpload.GetError<>"" Then
Response.Write("sorry, could not upload: "&objUpload.GetError)
Else
Response.Write("found "&objUpload.FileCount&" files...<br />")
For x=0 To objUpload.FileCount-1
Response.Write("file name: "&objUpload.File(x).FileName&"<br />")
Response.Write("file type: "&objUpload.File(x).ContentType&"<br />")
Response.Write("file size: "&objUpload.File(x).Size&"<br />")
Response.Write("image width: "&objUpload.File(x).ImageWidth&"<br />")
Response.Write("image height: "&objUpload.File(x).ImageHeight&"<br />")
If (objUpload.File(x).ImageWidth>200) Or (objUpload.File(x).ImageHeight>200) Then
Response.Write("image to big, not saving!")
Else
Call objUpload.File(x).SaveToDisk(Server.MapPath("Uploads"), "")
Response.Write("file saved successfully!")
End If
Response.Write("<hr />")
Next
Response.Write("thank you, "&objUpload("name"))
End If
End If
%>
<form action="<%=Request.ServerVariables( "Script_Name" )%>?action=1" enctype="multipart/form-data" method="POST">
File1: <input type="file" name="file1" /><br />
File2: <input type="file" name="file2" /><br />
File3: <input type="file" name="file3" /><br />
Name: <input type="text" name="name" /><br />
<button type="submit">Upload</button>
</form>
unedited.
The ShadowUpload sript is the original unedited one ithat you posted ie
anyone have any suggestions of what might be wrong. I am not getting an actual error message, but the pc processor usage seems to go a little crazy when it is trying to execute the script with the correct file size.
Posts: 155
Time spent in forums: 1 Day 2 h 58 m 13 sec
Reputation Power: 6
still hanging!
Thanks for the advice below. I did have script blocking checked on, so I unchecked NAV script blocking. I then tried to upload a normal sized picture, and the server just appeared to hang. With the correct sized picture upload, it gives the expected error message. Is there any way of debugging this to find out what step it is hangin at?
Posts: 31,109
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
I can tell you the line, but it's pointless.. it hangs when trying
to Open the file or Write to the file.
you either didn't really disable the Script Blocking, or didn't
Restart your computer - note that disabling the real time protection
is not relevant and won't help.
Posts: 155
Time spent in forums: 1 Day 2 h 58 m 13 sec
Reputation Power: 6
worked Great!
thanks for that suggestion. Turning off the script blocking and the reboot did the trick.
Quote:
Originally Posted by Shadow Wizard
I can tell you the line, but it's pointless.. it hangs when trying
to Open the file or Write to the file.
you either didn't really disable the Script Blocking, or didn't
Restart your computer - note that disabling the real time protection
is not relevant and won't help.
Posts: 155
Time spent in forums: 1 Day 2 h 58 m 13 sec
Reputation Power: 6
need to change uploaded image name to id number
Quote:
Originally Posted by Shadow Wizard
cheers, I've added reference to this thread in the section "Related Threads"
of the ShadowUpload main thread.
Thanks a lot for that. It is working very well. I had a couple more questions. I am able to display the images on the following page: The code in red shows the image in the "uploads" folder. The first issue is using this, I am only able to show image files with the JPEG extension. I wanted to know an approach to make a generic statement that would enable it to show JPG, GIF and PNG images without having to add 3 sepate image links for each extension type.
Code:
<%@LANGUAGE=VBScript%>
<%Function LinkURLs(tempTxt)
Dim regEx
Set regEx = New RegExp
regEx.Global = True
regEx.IgnoreCase = True
'Hyperlink Email Addresses
regEx.Pattern = "([_.a-z0-9-]+@[_.a-z0-9-]+\.[a-z]{2,3})"
tempTxt = regEx.Replace(tempTxt, "<a href=""mailto:$1"" class=""bluebold"">$1</a>")
'Hyperlink URL's
regEx.Pattern = "((www\.|(http|https|ftp|news|file)+\:\/\/)[_.a-z0-9-]+\.[a-z0-9\/_:@=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,| |>|<|;|\)])"
tempTxt = regEx.Replace(tempTxt, "<a href=""$1"" class=""bluebold"" target=""_blank"">$1</a>")
'Make <a href="www = <a href="http://www
tempTxt = Replace(tempTxt, "href=""www", "href=""http://www")
LinkURLs = tempTxt
End Function
%>
<%
' Define variables
dim recordsonpage, requestrecords, offset, allrecords, hiddenrecords, showrecords, lastrecord, recordcounter, pagelist, pagelistcounter
' DB connection
dim Conn
Set Conn = Server.CreateObject("ADODB.Connection")
sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("boards.mdb") & ";" & _
"Persist Security Info=True"
Conn.Open(sConnection)
' records per page
recordsonpage = 1
' count all records
allrecords = 0
set rs = conn.Execute("SELECT id, subject, indication, notes FROM notes where indication LIKE '%applicable%'")
do until rs.EOF
allrecords = allrecords + 1
rs.movenext
loop
' if offset is zero then the first page will be loaded
offset = request.querystring("offset")
if offset = 0 OR offset = "" then
requestrecords = 0
else
requestrecords = requestrecords + offset
end if
' opens database
set rs = conn.Execute("SELECT id, subject,indication, notes FROM notes where indication LIKE '%applicable%' ORDER BY id")
' reads first records (offset) without showing them
hiddenrecords = requestrecords
do until hiddenrecords = 0 OR rs.EOF
hiddenrecords = hiddenrecords - 1
rs.movenext
if rs.EOF then
lastrecord = 1
end if
loop
%>
<html>
<head>
<title>ALL RADIOLOGY NOTES</title>
<meta http-equiv="author" content="Tranzity">
</head>
<body bgcolor="#000080">
<p>
</table>
<table align="center" cellspacing="2" cellpadding="2" border="1" width="800">
<tr>
<td><% if requestrecords <> 0 then %><a href="notesformatted.asp?offset=<% = requestrecords - recordsonpage %>"><font color=#FFFFFF>Prev Page</font></a><% else %><font color=#FFFFFF>Prev Page</font><% end if %></td>
<td><% if lastrecord <> 1 then %> <a href="notesformatted.asp?offset=<% = requestrecords + recordsonpage %>">Next Page</a><% else %><font color=#FFFFFF>Next Page</font><% end if %></td>
</tr>
<%
pagelist = 0
pagelistcounter = 0
do until pagelist > allrecords
pagelistcounter = pagelistcounter + 1
%>
<a href="notesformatted.asp?offset=<% = pagelist %>"><% = pagelistcounter %></a>
<%
pagelist = pagelist + recordsonpage
loop
%>
</td>
</table>
</p>
<table cellspacing="0" cellpadding="0" border="0" width="800">
<%
' prints records in the table
showrecords = recordsonpage
recordcounter = requestrecords
do until showrecords = 0 OR rs.EOF
recordcounter = recordcounter + 1
%>
<%
Session("id")=rs("id")
%>
<tr>
<td><span style="text-transform: uppercase"><b><font color="#FFFFFF" size="5">SUBJECT: <% = rs("subject") %></b></span><br></td>
</tr>
<tr>
<tr>
<td><input type="button" value="Upload JPEG"
onclick="window.open('upload.asp')"></td>
</tr>
<tr>
<td><img src="uploads/<%=rs("id") %>.JPG"><br></td>
</tr>
<form method="post" action="displaynotes2.asp?print=yes"><tr>
<input type="hidden" name="ID" value="<%=rs("id")%>">
<input type="submit" name="Submit" value="Printable Format"></tr>
</form>
<tr>
<td><font color="#FFFFFF" size="5"><b>QUOTE:</b><br> <cite>"<%=replace((LinkURLs(rs("notes"))), vbcrlf, "<br>") %>"</cite></font></td>
</tr>
<%
showrecords = showrecords - 1
rs.movenext
if rs.EOF then
lastrecord = 1
end if
loop
%>
<%
' Closes connection
rs.close
Conn.close
%>
</body>
</html>
i created a Session variable for the id number of the record (in lime green in the above script)
the second question concerns adding the id value to the upload form script. I was trying to figure out how to have the uploaded image named as the id number from the session variable iinstead of whatever name it happens to have. Ie if its name is say familypic.JPG, i want the name to come up as say 6.JPG if the id passed from the previous page is 6. That way ie I can tie the image to the page without having to change its name to the id number prior to uploading. Any ideas would be great.
the upload form that I am trying is the example by Shadowiz:
Code:
<!-- #include file="ShadowUploader.asp" -->
<%
Dim objUpload
If Request("action")="1" Then
Set objUpload=New ShadowUpload
If objUpload.GetError<>"" Then
Response.Write("sorry, could not upload: "&objUpload.GetError)
Else
Response.Write("found "&objUpload.FileCount&" files...<br />")
For x=0 To objUpload.FileCount-1
Response.Write("file name: "&objUpload.File(x).FileName&"<br />")
Response.Write("file type: "&objUpload.File(x).ContentType&"<br />")
Response.Write("file size: "&objUpload.File(x).Size&"<br />")
Response.Write("image width: "&objUpload.File(x).ImageWidth&"<br />")
Response.Write("image height: "&objUpload.File(x).ImageHeight&"<br />")
If (objUpload.File(x).ImageWidth>200) Or (objUpload.File(x).ImageHeight>200) Then
Response.Write("image to big, not saving!")
Else
Call objUpload.File(x).SaveToDisk(Server.MapPath("Uploads"), "")
Response.Write("file saved successfully!")
End If
Response.Write("<hr />")
Next
Response.Write("thank you, "&objUpload("name"))
End If
End If
%>
<form action="<%=Request.ServerVariables( "Script_Name" )%>?action=1" enctype="multipart/form-data" method="POST">
File1: <input type="file" name="file1" /><br />
File2: <input type="file" name="file2" /><br />
File3: <input type="file" name="file3" /><br />
Name: <input type="text" name="name" /><br />
<button type="submit">Upload</button>
</form>
as for your first question, it's dead end. you'll need to revise the whole logic,
as you can't know in advance if the user will upload JPG, GIF, BMP or whatever
type of image. one option is to store the names in database, another option is to iterate
over all the files in the folder and show them.
as for your first question, it's dead end. you'll need to revise the whole logic,
as you can't know in advance if the user will upload JPG, GIF, BMP or whatever
type of image. one option is to store the names in database, another option is to iterate
over all the files in the folder and show them.