Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PLEASE HELP ON UPLOADING DOCUMENTS !!!!!!

Status
Not open for further replies.

ashw

MIS
Jun 10, 2002
61
CA
In the intranet I am developing, the user can add a new document to the web. he has to go to a page where he clicks on the the department name , a form to add the document to that deparment comes up. this form consist of document name , description, a browse button , upload document button and department name field. since it is intranet, the department name of the user is known when he logged on and stored in session variable and shown as such in the department name field. he then upload the document to the directory on the server. this directory is further divided into sub directories which are the department names. so that document should be uploaded to the selected department (sub directory). when he is finished the web page should show the department name as the title and list of all the documents of that deparment. but it is not happening. the documents are ending up in the main directory and not the sub-directories (departments) and the list also shows the list of the sub directories (departments). it is not considering department e. PLEASE help. here is the code
========================================================
ADD NEW DOCUMENT FORM CODE
========================================================
<!---CFincludes header, Css style sheet and Side Menu--->
<cfinclude template=&quot;/Header.cfm&quot;>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;><!--
function submitforms(){
Upload.submit()
Attachment.submit()
}
//--></SCRIPT>

<body>
<cfform action=&quot;Upload.cfm&quot; method=&quot;POST&quot; enablecab=&quot;No&quot; name=&quot;Upload&quot; enctype=&quot;multipart/form-data&quot; preservedata=&quot;Yes&quot;>
<table border=&quot;0&quot;>
<tr>
<th colspan=&quot;2&quot;>Add a New Department Document</th>
</tr>
<tr>
<td>Document Name</td>
<td>
<cfinput type=&quot;text&quot; name=&quot;wpTitle&quot;>
</td>
</tr>
<tr>
<td>Department</td>
<td>
<input type=&quot;hidden&quot; name=&quot;wpdept&quot;>
<cfoutput>#Session.Auth.Dept#</cfoutput></td>
</tr>
<tr>
<td></td>
<td>
<input type=&quot;hidden&quot; name=&quot;wptype&quot; value=&quot;7&quot;>
</td>
</tr>
<tr>
<td>Description</td>
<td>
<cfinput type=&quot;text&quot; name=&quot;wpDescription&quot;>
</td>
</tr>
<tr>
<td></td>
<td><input type=&quot;hidden&quot; name=&quot;wpDateCreated&quot; value=&quot;#CreateODBCDateTime(Now())#&quot;</td>
</tr>
<tr>
<td colspan=&quot;2&quot;>
<tr>
<td colspan=&quot;2&quot;>

<cfform action=&quot;upload.cfm&quot; method=&quot;POST&quot; enablecab=&quot;No&quot; name=&quot;Attachment&quot; enctype=&quot;multipart/form-data&quot; preservedata=&quot;Yes&quot;>
<input type=&quot;file&quot; name=&quot;wpAttachment&quot; size=&quot;40&quot; value=&quot;#wpID#&quot;
accept=&quot;application/msword,application/msexcel,application/pdf,text/html,application/rtf&quot; class=&quot;button2&quot;>
<tr>
<td colspan=&quot;2&quot;></td>
</cfform>
<tr>
<td colspan=&quot;2&quot;></tr>
<tr>
<td colspan=&quot;2&quot;>
<input type=&quot;submit&quot; value=&quot;Submit Forms&quot; onClick=&quot;submitforms()&quot;>
</td>
</tr>
</table>
</cfform>

</body>
<!---CFInclude Footer--->
<cfinclude template=&quot;/footer.cfm&quot;>
==================================================
UPLOAD.cfm CODE
===================================================
<cfinclude template=&quot;/Header.cfm&quot;>

<!---CF Directory to department directory--->
<cfdirectory action=&quot;LIST&quot; directory=&quot;d:\Intranet online documents\#wpdept#&quot; name=&quot;documents&quot; filter=&quot;&quot;>

<html>
<head>
<title>Untitled</title>
</head>

<body>
<CFFILE ACTION=&quot;UPLOAD&quot; FILEFIELD=&quot;wpAttachment&quot;
DESTINATION=&quot;D:\Intranet Online Documents\#wpdept#\&quot;
NAMECONFLICT=&quot;MAKEUNIQUE&quot;
ACCEPT=&quot;application/msword,application/msexcel,application/pdf,text/html,application/rtf&quot;>




<cfform action=&quot;DeleteDoc.cfm&quot; method=&quot;post&quot;>
<input type=&quot;submit&quot; name=&quot;Delete&quot; value=&quot;Delete&quot;>

<table width=&quot;75%&quot; border=&quot;1&quot;>
<tr>
<td colspan=&quot;4&quot;></td>
</tr>

<cfoutput>
<th colspan=&quot;4&quot;><b><font size=&quot;4&quot;>#wpdept# Documents</font></b></th>
</cfoutput>

<tr>
<td width=&quot;2%&quot;><input type=&quot;checkbox&quot; onClick=&quot;if (this.checked) CheckAll(this.form); else ClearAll(this.form)&quot;></td>
<td >&nbsp;</td>
<td><div align=&quot;center&quot;><font size=&quot;4&quot;><b><font size=&quot;3&quot;>Name</font></b></font></div></td>

<td width=&quot;9%&quot;>
<div align=&quot;center&quot;><font size=&quot;3&quot;><b>Document Size</b></font></div>
</td>
</tr>
<cfoutput query=&quot;Documents&quot;>

<CFIF #name# Contains &quot;.doc&quot;>
<cfset image = &quot;MSword.gif&quot;>
<CFelseIF #name# Contains &quot;.dot&quot;>
<cfset image = &quot;MSword.gif&quot;>
<cfelseif #name# Contains &quot;.xls&quot;>
<cfset image = &quot;MSExcel.gif&quot;>
<cfelseif #name# Contains &quot;.ppt&quot;>
<cfset image = &quot;MSPPT.gif&quot;>
<cfelseif #name# Contains &quot;.pdf&quot;>
<cfset image = &quot;pdf.gif&quot;>
<cfelseif #name# Contains &quot;.rtf&quot;>
<cfset image = &quot;rtf.gif&quot;>
<cfelseif #name# Contains &quot;.mdb&quot;>
<cfset image = &quot;MSAccess.gif&quot;>
<cfelseif #name# Contains &quot;.htm&quot;>
<cfset image = &quot;Html.gif&quot;>
<CFelse>
<cfset image = &quot;file.gif&quot;>
</CFIF>
<tr>
<cfif Name is not &quot;.&quot; and Name is not &quot;..&quot;>
<td width=&quot;2%&quot;><INPUT type=&quot;checkbox&quot; name=&quot;dID&quot; ></td>
<td><img src=&quot;/cfimages/#image#&quot;></td>
<td width=&quot;89%&quot;><a href=&quot;file://uwmspintranet/Intranet online documents/#wpdept#/#name#&quot; target=&quot;_blank&quot;>#name#</a></td>
<td width=&quot;9%&quot;>#size#</td>
</cfif>
</CFOUTPUT>
</tr>
</table>


</cfform>
</body>
</html>
<cfinclude template=&quot;/footer.cfm&quot;>


 

so at the moment the documents are been uploaded to the main root (D:\Intranet Online Documents\) or to a department directory (department a) under the main root but not into the correct department under department a?

if the documents are been uploaded to the main root then it is probably this line that is the problem!

<tr>
<td>Department</td>
<td><input type=&quot;hidden&quot; name=&quot;wpdept&quot;>
<cfoutput>#Session.Auth.Dept#</cfoutput></td>
</tr>

you are not providing a value for the wpdept, so when you come to upload the file, there is no value for this variable to CF is uploading the file to the D:\Intranet Online Documents\ directory.

add a value to the input type and give it a go.

Hope this helps!

Tony
 
the documents are uploaded to the main root.
the user can only add document of his department so
what should I have for value >#Session.Auth.Dept#
 
if Session.Auth.Dept holds the name of the subdirectory under the department name that you want to upload to then yes.

if it doesn't then you will have to add some code to say which sub department to upload to

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top