This topic is locked

Put file extension cap on uploads

2/9/2007 5:39:01 AM
ASPRunnerPro General questions
Z
zion4ever author

Hi,
Is it possible to allow only format .wmv and .rm for uploads?

How would I set this up.
Thank you in advance
Hans

J
Jane 2/9/2007

Hans,
to upload only .wmv and .rm file you need to edit ..._add.asp and ..._edit.asp file.

Find following code snippet:

' write file

rs("FieldName")= strValue

if strValue<>"" then _

WriteToFile Server.MapPath(GetUploadFolder("FieldName","") & strValue), GetRequestForm("file_FieldName")

and replace it with this one:

' write file

if strValue<>"" then

ext = UCase(right(strValue,3))

if ext="WMV" or ext=".RM" then

rs("FieldName")= strValue

WriteToFile Server.MapPath(GetUploadFolder("FieldName","") & strValue), GetRequestForm("file_FieldName")

end if

end if



where FieldName is your actual field name.

Z
zion4ever author 2/9/2007

Hi,
It still doesn't work. I get a: page cannot be displaye: possible programming error. I have the following code:
if not errorhappened and not (vartype(strValue)=11 and strValue=False) then

if isnull(strValue) then strValue=""

ctype = GetRequestForm("type_Player_in_action")

If ctype = "upload1" Then

' delete file

rs("Player in action") = Null

DeleteFile Server.MapPath(GetUploadFolder("Player in action","") & GetRequestForm("filename_Player_in_action"))

end if

If ctype = "upload2" Then
' write file

if strValue<>"" then

ext = UCase(right(strValue,3))

if ext="WMV" or ext=".RM" then

rs("Player in action")= strValue

WriteToFile Server.MapPath(GetUploadFolder("Player in action","") & strValue), GetRequestForm("file_Player_in_action")

end if

end if
call reporterror

end if

' update Website field

strValue=false

if evalues.exists("Website") then


strValue = evalues.Item("Website")
The fieldname is "player in action". Why is it sometimes underscored and sometimes not?
TIA

J
Jane 2/12/2007

Please publish your project on Demo Account and send to [email=support@xlinesoft.com]support@xlinesoft.com[/email] a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.