Persits.Upload

I moved a site here that has a script to upload photos to a real estate site.
But I need to change something to correct the following error:

Code:
D:\hshome\alcadmin\arizonarenttoown.com\admin\PIC_Upload.asp

Persits.Upload.1 error '800a0028'

This feature has been disabled by system administrator. Use File.SaveAsVirtual instead.

/admin/PIC_Upload.asp, line 25

Its something to do with this but I don't know how to correct: http://www.aspupload.com/object_upload.html#SaveVirtual

If I paste part of the code to my script could someone help me out if it is a simple fix?

Thanks! Code below:
line 25 would be: File.SaveAs Path & "\" & Answer

Code:
Set Upload = Server.CreateObject("Persits.Upload")
'On Error Resume Next
' we use memory uploads, so we must limit file size
Upload.SetMaxSize 1048576, True	' Limit files to 1MB
' Save to memory. Path parameter is omitted
Upload.Save
txtID = Upload.Form("homeID")
txtPicture = Upload.Form("txtPicture")
txtPicNum = Upload.Form("txtPictuspamSpamm")
txtProp = Upload.Form("txtProperty")

Response.write(Server.MapPath("PIC_Upload.asp"))

Path = "D:\hshome\alcadmin\arizonarenttoown.com\admin\properties"

Upload.OverwriteFiles = True
' Save files to it. Our form has only one file item
' but this code is generic.
	For Each File in Upload.Files
	   Answer = txtPicNum & "_" & txtID & RIGHT(File.FileName, 4)
	   File.SaveAs Path & "\" & Answer
		' Database Open
 
Hi

You may not need to use saveasvirtual option as you are using save to memory option.
Try the code below.

Cheers
Yogesh

'Path = "D:\hshome\alcadmin\arizonarenttoown.com\admin\properties"
Path = "/admin/properties"

Upload.OverwriteFiles = True
' Save files to it. Our form has only one file item
' but this code is generic.
For Each File in Upload.Files
Answer = txtPicNum & "_" & txtID & RIGHT(File.FileName, 4)
' File.SaveAs Path & "\" & Answer
File.SaveAs Path & "/" & Answer
' Database Open
 
Hi

Sorry for that. U'll have to use virtual. Below code is tested and works. Plz try and let me know.
U will have to create a subdirectory "upload" under the folder where u run this script.

Cheers
Yogesh

<%
Set Upload = Server.CreateObject("Persits.Upload")

Upload.OverwriteFiles = False
' On Error Resume Next
' we use memory uploads, so we must limit file size
Upload.SetMaxSize 100000, True

' Save to memory. Path parameter is omitted
Upload.Save

Set File = Upload.Files("FILE1")
If Not File Is Nothing Then
' Obtain file name
Filename = file.Filename

' check if file exists in c:\upload under this name
If Upload.FileExists("upload/" & filename ) Then
Response.Write "File with this name already exists."
Else
' otherwise save file
File.SaveAsVirtual "upload/" & File.Filename
Response.Write "File saved as " & File.Path
End If
Else ' file not selected
Response.Write "File not selected."
End If
%>
 
Sorry for so many questions, but here is my original code, do I omit what you didn't include in your example or ?

Thanks for the help!!!


Code:
<%@ LANGUAGE=VBSCRIPT %>
<!-- #include file="adovbs.inc" -->
<%response.buffer = TRUE%>
<%
Set Upload = Server.CreateObject("Persits.Upload")
'On Error Resume Next
' we use memory uploads, so we must limit file size
Upload.SetMaxSize 1048576, True	' Limit files to 1MB
' Save to memory. Path parameter is omitted
Upload.Save
txtID = Upload.Form("homeID")
txtPicture = Upload.Form("txtPicture")
txtPicNum = Upload.Form("txtPictuspamSpamm")
txtProp = Upload.Form("txtProperty")

Response.write(Server.MapPath("PIC_Upload.asp"))

'Path = "D:\hshome\alcadmin\arizonarenttoown.com\admin\properties"
Path = "/admin/properties"

Upload.OverwriteFiles = True
' Save files to it. Our form has only one file item
' but this code is generic.
	For Each File in Upload.Files
	   Answer = txtPicNum & "_" & txtID & RIGHT(File.FileName, 4)
	   'File.SaveAs Path & "\" & Answer
		File.SaveAs Path & "/" & Answer
		'Database Open

	Set oConn = Server.CreateObject("ADODB.Connection")
	oConn.Open "Driver={MySQL ODBC 3.51 Driver}; Server=mysql1.g********.com; Database=alcadmi_main; UID=admin; PWD=******; Option=3"

		sSQL = "UPDATE rent_homes " & _
  		"SET Picture" & txtPicNum &" = '" & Answer & "' WHERE homeID=" & txtID & ";"

		oConn.Execute sSQL
		

			If Err.Number = 0 Then
			   Session("strErrorID_result") = "Success: "
			   Session("strErrorDescription_result") = UCASE(Answer) & " was updated."

		oConn.Close
		Set oConn = Nothing

				   Response.Redirect("property_edit.asp?homeID=" & txtID)
			Else
			Session("strErrorID_result") = Err.Number
			Session("strErrorDescription_result") = Err.Description
								oConn.Close
								Set oConn = Nothing
				   Response.Redirect("property_edit.asp?homeID=" & txtID)
			End If	   
	Next
%>
 
I am ok to answer the questions as far as I understand them, so plz feel free to post your Qs untill it gets resolved.:)

Ok here is the exact snippet where you need to change (* plz note the SaveAsVirtual) -

Existing -
For Each File in Upload.Files
Answer = txtPicNum & "_" & txtID & RIGHT(File.FileName, 4)
'File.SaveAs Path & "\" & Answer
File.SaveAs Path & "/" & Answer
'Database Open

Change To
For Each File in Upload.Files
Answer = txtPicNum & "_" & txtID & RIGHT(File.FileName, 4)
File.SaveAsVirtual Path & "/" & Answer
'Database Open

Rest all remains same. Hope it helps.

Cheers
Yogi
 
Ok I created the upload subdirectory.

Now I get:
Save method must not be called more than once.

/admin/PIC_Upload.asp, line 22

Line 22 is:
Code:
Upload.Save

Just our of curiosity I tried removing that line and the script appears to work without errors but the file was not actually uploaded.

You had asked that I create a folder upload under the directory of the script but I was already using a folder properties that referenced in the path statement.

So I changed:
If Upload.FileExists("upload/" & filename ) Then
and
File.SaveAsVirtual "upload/" & File.Filename

to
If Upload.FileExists("properties/" & filename ) Then
and
File.SaveAsVirtual "properties/" & File.Filename


That seems to work and I can upload photos now.

But, if I go back to edit or change and existing photo the photo will not change and I see filenames like:
1_57.jpg
1_57(2).jpg
1_57(3).jpg

But maybe it had that problem before I moved to this server, not sure, I just took over the website.

Thanks for the help Yogi !!
 
My pleasure George

Good to know that the upload is working now.
BTW while exchanging messages I put the following line in the code -
Upload.OverwriteFiles = False
Which earlier was
Upload.OverwriteFiles = True

So whenever there is existing file with same name as file being uploaded then the new file will be created with some extension.
So you are getting it -
1_57.jpg
1_57(2).jpg
1_57(3).jpg

You may turn this feature ON/OFF by setting True or False depending on your requirement. But better to keep it False as there is always a chance that users will use very generic names for their images. like house.jpg, James.jpg etc. So one user can overwrite the other users pic.

Wish u good luck in your project.
I am into SEM and SEO. If have any requirements for your site or your client's site plz IM me.

Cheers
Yogi
 
The way it was working before is that when you up load a pic it changes the names of the pics to
1_57
2_57
3_57

Its a real estate site so when you edit a listing it adds the id number for that property and just puts 1,2,3 etc in front.

I will play with it and figure it out and will email you about some other work.

thanks!
-George
 
Back
Top