Pure ASP Upload Add On Pack Support Product Page

Rename file error

Reported 16 Mar 2010 17:50:32
1
has this problem
16 Mar 2010 17:50:32 MX Addict posted:
Since updating to PAU 3.0.16 problems with renaming file.

Uploading file with same name [intro.jpg] as renaming gives error:

intro.jpg renames intro.jpg give error
somename.jpg renames intro.jpg works perfectly

Runtimefout Microsoft VBScript (0x800A0035)
Kan het bestand niet vinden
/epicurus/ScriptLibrary/incPUAddOn.asp, line 176



<
%'*** Pure ASP File Upload 3.0.16
' Process form form1
Dim pau, DMX_uploadAction, UploadRequest, UploadQueryString, pau_thePath, pau_nameConflict, pau_saveWidth, pau_saveHeight
Set pau = new PureUpload
pau.ScriptLibrary = "../ScriptLibrary"
pau.TimeOut = 300
pau.ConflictHandling = "over"
pau.StoreType = "file"
pau.ProgressTemplate = "mac_look.htm"
pau.ProgressWidth = 400
pau.ProgressHeight = 100
pau.UploadFolder = """../images/projects/""& (rsProjects.Fields.Item(""projectnumber"").Value)"
pau.ProcessUpload
pau.SaveAll
%>
<
%' *** Rename Uploaded Files 1.8.1
If (CStr(Request.QueryString("GP_upload")) <> "") Then
  Dim REUF_renameMask
  REUF_renameMask = "intro.##ext##"
  RenameUploadedFiles pau_thePath, pau_nameConflict, REUF_renameMask
end if
%>


Replies

Replied 19 Mar 2010 12:35:58
19 Mar 2010 12:35:58 Patrick Woldberg replied:
I checked our source code and found this a bug, it only occur when using overwrite as conflict handling and the filename of the uploaded file is the same as the file to rename to.

Small fix:

On line 172 in the incPUAddOn.asp change the line to:
If REUF_fso.FileExists(GetPhysicalPath(REUF_thePath & REUF_fileNameOnly)) And REUF_fileNameOnly <> REUF_newFileName Then
Replied 19 Mar 2010 14:14:03
19 Mar 2010 14:14:03 MX Addict replied:
Thanks Patrick,

This problem is solved. But still another problem with ASP Upload Add On Pack.

files like: test.pdf recorded, uploads and rename

files like: test[34].pdf recorded, uploads but NOT rename

PAU 3.0.16
Rename Uploaded Files 1.8.1
DW insert behaviour



<
%'*** Pure ASP File Upload 3.0.16
' Process form form1
Dim pau, DMX_uploadAction, UploadRequest, UploadQueryString, pau_thePath, pau_nameConflict, pau_saveWidth, pau_saveHeight
Set pau = new PureUpload
pau.ScriptLibrary = "../ScriptLibrary"
pau.ConflictHandling = "uniq"
pau.StoreType = "file"
pau.ProgressTemplate = "mac_look.htm"
pau.ProgressWidth = 400
pau.ProgressHeight = 100
pau.UploadFolder = """../images/projects/""& (rsNews.Fields.Item(""projectnumber"").Value)"
pau.ProcessUpload
pau.SaveAll
%>
<
%' *** Rename Uploaded Files 1.8.1
If (CStr(Request.QueryString("GP_upload")) <> "") Then
  Dim REUF_renameMask
  REUF_renameMask = (rsNews.Fields.Item("projectnumber").Value)&"_newsitem.##ext##"
  RenameUploadedFiles pau_thePath, pau_nameConflict, REUF_renameMask
end if
%>

Replied 14 Apr 2010 18:55:25
14 Apr 2010 18:55:25 MX Addict replied:
Hello DMX,

We are a month further after visiting live support two times and still NO solution or extension-update. When can I and my customers expected an version update....
Replied 05 May 2010 15:31:30
05 May 2010 15:31:30 MX Addict replied:
ALMOST TWO MONTHS FURTHER AND STILL NO SOLUTION OR FIX. THIS EXTENSION IS NOT WORKING WELL WITH PAU 3.0.17

WHY ONLY UPDATING PAU AND NOT THIS EXTENSION.

Replied 11 Jun 2010 12:54:34
11 Jun 2010 12:54:34 MX Addict replied:

3 months further and still no fix

Replied 13 Sep 2010 14:49:24
13 Sep 2010 14:49:24 Miroslav Zografski replied:
Hello, this is a follow up.

As a precaution I need to point out that for some systems "[" and "]" are invalid characters.

To have your rename script to allow [] brackets you need to remove them from the pau_RemoveInvalidChars function found in incPUClass.asp and incPUAddOn.asp.
Then you need to edit the incPUClass.asp file as follows:
Change Line 830 to :

AddUploadFormRequest Control.Name, Control.FileName, Control.ContentType, Control.FileName


Change Line 752 to :

Control.Value = pau_RemoveInvalidChars(real_fn)


Regards,
Replied 02 Dec 2010 15:55:09
02 Dec 2010 15:55:09 MX Addict replied:
Hi DmxZone,

you really need to update this extension. Still problems with renaming filename when uploading files which contains al sorts of signs in their filename like #(<{}[] etc...

The solution doesn't work at all...
Replied 17 Mar 2011 17:16:52
17 Mar 2011 17:16:52 nigel morris replied:
i fixed it this way

Add the function from pure upload 2 to your page


Function pau_RemoveInvalidChars(str)
  Dim newStr, ci, curChar, Invalid
  Invalid = "$@<>[]{}():;=^|*!/\%?,'""  "
  for ci = 1 to Len(str)
    curChar = Mid(str,ci,1)
    if InStr(Invalid, curChar) = 0 then
      newStr = newStr & curChar
    end if
  next
  pau_RemoveInvalidChars = Trim(newStr)
End Function


Then run the function on the incPUAddOn.asp file


if REUF_lastPos > 0 Then
							REUF_curExt = mid(REUF_curName,REUF_lastPos+1,Len(REUF_curName)-REUF_lastPos)	
							REUF_curName = mid(REUF_curName,1,REUF_lastPos-1)
						end if
						'Custom Remove invalid characters
						REUF_newFileName = pau_RemoveInvalidChars(REUF_curName) 
  						'End Custom Remove
  						
						REUF_newFileName = Replace(REUF_renameMask,"##name##",REUF_curName)
						REUF_newFileName = Replace(REUF_newFileName,"##ext##",REUF_curExt)	  
						REUF_newFileName = Replace(REUF_newFileName,"##year##",Year(Now))	  
						REUF_newFileName = Replace(REUF_newFileName,"##month##",Month(Now))	  
						REUF_newFileName = Replace(REUF_newFileName,"##day##",Day(Now))	  
						REUF_newFileName = Replace(REUF_newFileName,"##hour##",Hour(Now))	  
						REUF_newFileName = Replace(REUF_newFileName,"##minute##",Minute(Now))	  
						REUF_newFileName = Replace(REUF_newFileName,"##second##",Second(Now))



Then run the function on the insert/upload form

MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, MM_IIF(UploadFormRequest("docFile"), pau_RemoveInvalidChars(UploadFormRequest("docFile")), UploadFormRequest("upload_org_docFile"))) ' adVarWChar



Edited by - nigel morris on 17 Mar 2011  17:28:09

Reply to this topic