Advanced Multi Uploader Support Product Page

This topic was archived

Upload to Variable Folder

Asked 18 Dec 2008 06:13:02
1
has this question
18 Dec 2008 06:13:02 Cain Goettelman posted:
Hi trying to upload to a variable folder.
User select a sub direcotry via drop down list. This form posts the data to the Page with the multi upload form. I am using the following code to request the selected directory value and then add it to the pau.UploadFolder.

If I write the value of pau.UploadFolder to the page I get the correct directory path.
When I upload a file the script says the file was uploaded. However once I check the directory on the server there is no file.
If I hard code the exact same directory files upload and are saved as expected.
What could be wrong with how I am requesting the value and setting pau .UploadFolder equal to it?


<
%Dim ulDirectory
ulDirectory = trim(Cstr(Request.Form("ulDirectory")))
Response.write(ulDirectory) & "<br/>"
%>
<
%'*** Pure ASP File Upload 3.0.12
' Process form upload1
Dim pau, DMX_uploadAction, UploadRequest, UploadQueryString, pau_thePath, pau_nameConflict, pau_saveWidth, pau_saveHeight
Set pau = new PureUpload
pau.ScriptLibrary = "ScriptLibrary"
pau.ConflictHandling = "error"
pau.StoreType = "file"
pau.ProgressTemplate = "lab.htm"
pau.ProgressWidth = 200
pau.ProgressHeight = 140
pau.UploadFolder = """images/designs/"" & ulDirectory & ""/"""
pau.AllowedExtensions = "GIF,JPG,JPEG,BMP,PNG" ' "images"
pau.ProcessUpload
pau.SaveAll
%>

Replies

Replied 18 Dec 2008 07:21:47
18 Dec 2008 07:21:47 Cain Goettelman replied:
I read the tutorial on organized folder and attempted to apply it to my situation. However the files are saved to the images/design/ directory on the server. It looks like the UploadFormRequest portion of the path is being ignored.
The follow code contains a routine to allow the creation of a new directory and then automatically selects this new directory for uploading.
I moved the <select></select> list to be within the Upload form rather than have it be a separate form that posts back to the same pageck
I also checked to be sure that I did not use any reserved variable names or reuse any variable names in the code I added so as not to conflict with the ASP Upload code. I am using Advnaced Multi Upload on this page.

Looking for suggestion on how to fix the code so the variable directory will work with both ASP Upload and SIP 2.5.



<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<
%Dim DesignDirectory
if Request.QueryString("FolderName") <> "" then
    DesignDirectory = Replace(Request.QueryString("FolderName")," ","_")
end if
%>
<!--#include file="ScriptLibrary/incPU3Class.asp" -->
<!--#include file="ScriptLibrary/incPU3Utils.asp" -->
<
%'*** Pure ASP File Upload 3.0.12
' Process form upload1
Dim pau, DMX_uploadAction, UploadRequest, UploadQueryString, pau_thePath, pau_nameConflict, pau_saveWidth, pau_saveHeight
Set pau = new PureUpload
pau.ScriptLibrary = "ScriptLibrary"
pau.ConflictHandling = "error"
pau.StoreType = "file"
pau.ProgressTemplate = "circle.htm"
pau.ProgressWidth = 500
pau.ProgressHeight = 150
pau.UploadFolder = """images/designs/"" & UploadFormRequest(""ulDirectory"")"
pau.Required = true
pau.AllowedExtensions = "GIF,JPG,JPEG,BMP,PNG" ' "images"
pau.ProcessUpload
pau.SaveAll
%>
<% 
Dim DedsignPath

sub ListFolderContents(DesignPath)

     dim fs, folder, file, item, url

     set fs = CreateObject("Scripting.FileSystemObject")
     set folder = fs.GetFolder(DesignPath)

if folder.Name <> "designs" and folder.Name <> "_notes" and folder.Name <> "TileGroup0" then
    Dim SelectDirectory
    if folder.Name = DesignDirectory then
        SelectDirectory = " Selected"
    end if
     response.write"<option value=""" & trim(Cstr(folder.Name))  & """" & SelectDirectory & ">" & trim(Cstr(folder.Name)) & "</option>"  & vbCRLF
end if
         
     'Display a list of sub folders.
if folder.SubFolders.Count > 0 then
     for each item in folder.SubFolders
       ListFolderContents(item.Path)
     next
end if

     'Display a list of files.

     'for each item in folder.Files
       'url = MapURL(item.path)fa
       'Response.Write("<li><a href=""" & url & """>" _
         '& item.Name & "</a> - " _
         '& item.Size & " bytes, " _
         '& "last modified on " & item.DateLastModified & "." _
         '& "</li>" & vbCrLf)
     'next

   end sub
   
function MapURL(DesignPath)

     dim rootPath, url

     'Convert a physical file path to a URL for hypertext links.

     rootPath = Server.MapPath("/")
     url = Right(path, Len(DesignPath) - Len(rootPath))
     MapURL = Replace(url, "\", "/")

   end function
%>
<
%If Request.QueryString("FolderName") <> "" then
dim fso,foldername, newfolder, newfolderpath
newfolder = Request.QueryString("FolderName")
newfolder = Replace(newfolder," ","_")
newfolderpath = "D:\inetpub\" & newfolder
	set fso=Server.CreateObject("Scripting.FileSystemObject")
 If fso.FolderExists(newFolderPath) = True Then
    Response.Write("The <strong>" & newfolder & "</strong> folder already exists")
 Else
	set foldername=fso.CreateFolder("D:\inetpub\" & newfolder)
	set foldername=nothing
	set fs=nothing
Response.Write("<br />The <strong>" & newfolder & "</strong> folder has been created")
 End If 
End If
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Design Upload Manager</title>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script type="text/javascript"><%=pau.generateScriptCode()%></script>
<script src="ScriptLibrary/incPU3.js" type="text/javascript"></script>
</head>

<body>
<h1>Design Upload Management</h1>
<form id="CreateDirectory" name="CreateDirectory" method="get" action="DesignUploadManager3.asp">
  <strong>Create Folder Name:</strong>
  <input name="FolderName" type="text" id="FolderName" size="50" />
  <input type="submit" name="Submit" id="Submit" value="Submit" />
</form>

<div style="border:thin; border-color:#0000CC;">
  <h3>Select A Design Category</h3>
</div>
<form name="FlashUpload" method="post" action="DesignUploadManager3.asp">
<select name="ulDirectory">
<% ListFolderContents(Server.MapPath("images/designs/")) %>
</select>
<br/>
  <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','name','upload1','width','400','height','150','align','middle','id','upload1','src','dmxPureUpload','quality','best','flashvars','<%=pau.FlashVars()%>','scale','noscale','wmode','transparent','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','dmxPureUpload' ); //end AC code
</script>
  <noscript><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" name="upload1" width="400" height="150" align="middle" id="upload1">
    <param name="FlashVars" value="<%=pau.FlashVars()%>" />
    <param name="movie" value="dmxPureUpload.swf" />
    <param name="quality" value="best" />
    <param name="scale" value="noscale" />
    <param name="wmode" value="transparent" />
    <embed src="dmxPureUpload.swf" id="upload1" quality="best" flashvars="<%=pau.FlashVars()%>" scale="noscale" wmode="transparent" type="application/x-shockwave-flash" width="400" height="150" pluginspage="http://www.macromedia.com/go/getflashplayer" />
  </object></noscript>
  <input type="hidden" name="Filedata" />
</form>
</body>
</html>



Thanks
Cain
Replied 15 May 2009 15:33:35
15 May 2009 15:33:35 simon jennings replied:
I seem to be having the same problem with php version.

Trying to multi upload to folder "images/".$_POST['foldername'] but the files just get put in images/

Help please!
Replied 04 Jul 2009 12:15:31
04 Jul 2009 12:15:31 Patrick Julicher replied:
Hi Cain,

I have the upload to a variable folder working using this following code. Users select the Foldername from a drop down list names FolderName.

pau.UploadFolder = """media/"" &UploadFormRequest(""Foldername"")"


Works like a charm!

Kind regards, Patrick
Replied 04 Jul 2009 12:17:00
04 Jul 2009 12:17:00 Patrick Julicher replied:
Hi Simon,

Have a look at the previous post. I don't know if this works for PHP, but the UploadFormRequest is essential to get this to work!

Kind regards, Patrick

Reply to this topic