user ability to upload images

missjean

New Member
Hi...I am a pre-newbie. I am completely unqualified to build a web site but have somehow found myself doing so anyway. I have no formal education and have taught myself what little I know. That being said (keeping in mind i know very little lingo) could anyone steer me in the right direction to find out how to incorporate the ability for users to upload images to a web site. My client offers a service to have pictures or artwork imprinted on a variety of products such as t-shirts, mugs, etc....and has been very successful doing so with customers just mailing in the pictures. She would like to offer the ability for users to upload those same images online. I have no clue how to do this. I am currently using frontpage. Can I do this on my own or is it a software package i need to buy or scripting I can add....or what? Please help!
 

thrive

New Member
Do you know what technology your web site can serve up? Asp, Php, Cold Fusion, Java, anything? You'll need to know this to know what script to use. The script you're looking for is fairly common.
 

missjean

New Member
scripting languages

Thanks for responding...The server which hosts the web site is Network Solutions. They offer the following info....

Network Solutions supports the following scripting languages and versions:

n PERL

o Perl for Unix v. 5.85

o ActivePerl v. 5.6.1

n JavaScript

n ASP

n PHP v. 4

n ASP Net

n Cold Fusion MX
 

thrive

New Member
This isn't the cleanest solution, but it works. Copy the below and paste it in a file called upload.asp in the root of your web server.

============================================================

<%
if request("upload") = "now" then

Server.ScriptTimeout=1000
ForWriting = 2
adLongVarChar = 201
lngNumberUploaded = 0
On Error Resume Next

noBytes = Request.TotalBytes
binData = Request.BinaryRead (noBytes)
Set RST = CreateObject("ADODB.Recordset")
LenBinary = LenB(binData)
strDataWhole = LenB(binData)

if LenBinary > 0 Then
RST.Fields.Append "myBinary", adLongVarChar, LenBinary
RST.Open
RST.AddNew
RST("myBinary").AppendChunk BinData
RST.Update
strDataWhole = RST("myBinary")
End if

strBoundry = Request.ServerVariables ("HTTP_CONTENT_TYPE")
lngBoundryPos = instr(1,strBoundry,"boundary=") + 8
strBoundry = "--" & right(strBoundry,len(strBoundry)-lngBoundryPos)

Set dPassword = ParseForm("Password")
Set dOptions = ParseForm("Options")

Response.Write ParseForm("Password").item(0) & ""
Response.write dPassword.item(0) & ""
response.Write ParseForm("TArea").item(0) & ""

SavePath = Server.MapPath("/") & "\"

intCount = dOptions.count
if intCount > 0 Then
For x = 0 To intCount
Select Case dOptions.item(x)
Case "Raw"
Raw = True
Case "Boundry"
Boundry = True
End Select
Next
Else
Raw = False
Boundry = False
End if

if Raw Then
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso_OpenTextFile(SavePath & "\raw.txt", ForWriting, True)
f.Write strDataWhole
Set f = nothing
Set fso = nothing
End if

lngCurrentBegin = instr(1,strDataWhole,strBoundry)
lngCurrentEnd = instr(lngCurrentBegin + 1,strDataWhole,strBoundry) - 1

countloop = 0

Do While lngCurrentEnd > 0
strData = mid(strDataWhole,lngCurrentBegin, (lngCurrentEnd - lngCurrentBegin) + 1)
lngBeginFileName = instr(1,strdata,"filename=") + 10
lngEndFileName = instr(lngBeginFileName,strData,chr(34))

if lngBeginFileName = lngEndFileName and lngNumberUploaded = 0 Then

Response.Write "<H2> The following Error occured.</H2>"
Response.Write "You must Select at least one file To upload, and it must be in order from the top form."
Response.Write "<BR><BR>Hit the back button, make the needed corrections and resubmit your information."
response.Write "<BR><BR><INPUT type='button' onclick='history.go(-1)' value='<< Back' id='button'1 name='button'1>"
Response.End
End if

if lngBeginFileName <> lngEndFileName and lngBeginFileName - 10 <> 0 Then
strFilename = mid(strData,lngBeginFileName,lngEndFileName - lngBeginFileName)

if Boundry Then
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso_OpenTextFile(SavePath & "\raw_" & lngNumberUploaded & ".txt", ForWriting, True)
f.Write strData
Set f = nothing
Set fso = nothing
End if

tmpLng = instr(1,strFilename,"\")
Do While tmpLng > 0
PrevPos = tmpLng
tmpLng = instr(PrevPos + 1,strFilename,"\")
Loop

FileName = right(strFilename,len(strFileName) - PrevPos)
' ---------------------------------------------------------------------------------------------------------------------
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists(SavePath & "\" & FileName) then
%>
<b><%=FileName%></b> already exists!<br><br>
Hit the back button, make the needed corrections and resubmit your information.<br><br>
<input type='button' onclick='history.go(-1)' value='<< Back' id='button'1 name='button'1>
<%
Set fso = nothing
Response.End
end if
Set fso = nothing
' ---------------------------------------------------------------------------------------------------------------------
str_type = right(FileName,4)
if str_type = "tiff" or str_type = ".mpg" or str_type = "mpeg" or str_type = ".avi" or str_type = ".mov" or str_type = ".eps" then
%>
<b><%=str_type%></b> format is not permitted!<br><br>
Hit the back button, make the needed corrections and resubmit your information.<br><br>
<input type='button' onclick='history.go(-1)' value='<< Back' id='button'1 name='button'1>
<%
Response.End
end if
' ---------------------------------------------------------------------------------------------------------------------
lngCT = instr(1,strData,"Content-Type:")

if lngCT > 0 Then
lngBeginPos = instr(lngCT,strData,chr(13) & chr(10)) + 4
Else
lngBeginPos = lngEndFileName
End if
lngEndPos = len(strData)

lngDataLenth = (lngEndPos - lngBeginPos) -1
strFileData = mid(strData,lngBeginPos,lngDataLenth)
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso_OpenTextFile(SavePath & "\" & FileName, ForWriting, True)
f.Write strFileData
Set f = nothing
Set fso = nothing

lngNumberUploaded = lngNumberUploaded + 1

End if

lngCurrentBegin = lngCurrentEnd
lngCurrentEnd = instr(lngCurrentBegin + 9 ,strDataWhole,strBoundry) - 1

countloop = countloop + 1
if countloop = 100 Then
Response.Write "looped 100 times terminating script!"
if rstLog.State Then rstLog.close
if conn.State Then conn.Close

Response.End
End if
loop
if rstLog.State Then rstLog.close
if conn.State Then conn.Close

response.redirect("upload.asp")
response.end()
end if
' ----------------------------------------------------------------------------------------------------
%>
Upload images through this form.
<form enctype="multipart/form-data" action="upload.asp?upload=now" method="post" id="form1" name="form1">
<input name="File1" size="60" type="file"><br>
<br>
<input type="submit" class="button" value="Upload now!">
</form>
 

missjean

New Member
I do not see an upload.asp folder in the root directory. these are all I found:

backup
cgi-bin
htdocs
public_html
 

thrive

New Member
create a new file called upload.asp and paste what I put in the comment above into it. place that file in the public_html folder. then go to your site /upload.asp to use it
 

missjean

New Member
This is frustrating...I went to the file manager...pasted the info you supplied me into a new file which I named upload.asp and.....this is the message I got:

Can not open file: upload.asp

yikes...what am I doing wrong.
 

ISDProductions

New Member
open a new notepad document, paste the above code. choose, file, save as. change the file type to all, name your file upload.asp upload to your root directory
 

StephanieCordray

New Member
why not try an image gallery such as Gallery? Users can register and you can specify who has upload permissions from the admin control. That way you can sort of police the site and make sure only what you want to allow is allowed.
 

DLPerry

New Member
missjean said:
Hi...I am a pre-newbie. I am completely unqualified to build a web site but have somehow found myself doing so anyway. I have no formal education and have taught myself what little I know. That being said (keeping in mind i know very little lingo) could anyone steer me in the right direction to find out how to incorporate the ability for users to upload images to a web site. My client offers a service to have pictures or artwork imprinted on a variety of products such as t-shirts, mugs, etc....and has been very successful doing so with customers just mailing in the pictures. She would like to offer the ability for users to upload those same images online. I have no clue how to do this. I am currently using frontpage. Can I do this on my own or is it a software package i need to buy or scripting I can add....or what? Please help!

I use and highly recommend MasterFormV4. This formhandler can do it all I think, including accepting image file uploads. Very easy to set-up and customize, and you can specify image types, size, etc. too. Great Users Manual and documentation, and willmaster is always adding new stuff (which license holders get free of course).
Of course this is JMHO :) And yes, I am an affiliate, but I honestly would (and have) recommend this formhandler regardless. It is that good. If you prefer to get it without giving me credit (has no effect on price) you can use this the non-affiliate link --> http://willmaster.com/master/formV4/.
 
Top