Uploading files on a RaQ4 with Chilisoft/MySQL

File upload on a RaQ running MySQL/Chilisoft is relatively simple but has practical limitations that have been overcome on MS platforms using Pure ASP Upload. The key issue is that the CHili ASP engine on the RaQ will only allow a single file to be uploaded at a time and the VBScript used on the upload page prohibits the use of any other Response or Request handlers.

The method describes here allows a user to upload a chosen file to a folder location on the RaQ server. Ideally the file name should be changed from the browsed fileName to something shorter. It can then be accessed using a database call from the MySQL database whenever it needs to be displayed.

 

File upload - Issues

Read also see tutorial on connection using ChiliAsp by Greg Olone.

  • You can only upload one browsed file at a time
  • You cannot use Response or Request VBScript actions on the ASP upload page so VBScript cannot be used to change the file upload name from the user's C:\somedirectory\otherdirectory\long spaced out filename.jpg. This long filename will appear in the file upload folder on the server.

Step 1

Create a file upload page containing a form with a file selection input field. This will contain the code below:

<form name="form" method="post" enctype="multipart/form-data" action="uploadPage.asp">
<input type="file" name="inputFile">
<input type="submit" name="upload" value="Send  File">

Step 2

Create an upload page called "uploadPage.asp". This just needs some text to inform the user that his file has been uploaded and what to do next.

Note that it cannot contain expressions such as "Request.Form("customerName")

File code for the upload page  - uploadPage.asp:

<%@LANGUAGE="VBSCRIPT"%>
<% Option Explicit %>
<%
Response.Expires = 0
set fbase = Server.CreateObject("Chili.Upload.1")
Dim strFileName
strFileName = fbase.SourceFileName
fbase.SizeLimit = 100000
fbase.SaveToFile("../../sites/siten/web/userUploads/" & strFileName)
%>

Then all the HTML stuff...

The full file path from the server root is required and on a RaQ will look something like that shown above. In this case a folder has been previosly created on the web site called "userUploads". The uploaded file is saved in this folder using the full strFileName pulled from the previous page.

To use the files in your dynamic pages just link the image placeholder to them using a term such as

<img src="<%=LogoName%>">  where LogoName="../userUploads/strFileName"

Remember case sensitivity.

Jim Raff

Ancient! Ex Mngt Consultant, Brit, trying to get a mega-site going covering most apsects of the UK building industry including suppliers,traders, special interest goups, Govt, regulations etc. with almost no financial or other support.

Self-taught programmer, engineer/scientist.

See All Postings From Jim Raff >>

Comments

Be the first to write a comment

You must me logged in to write a comment.