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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Photograph Upload 2

Status
Not open for further replies.

Airpan

Technical User
Jun 14, 2005
172
US
I am researching being able to upload photographs. I found this FAQ: faq329-1869
I don't know if anyone has had experience with photograph upload but the FAQ points out a simple way to do so using just ASP and VB. I had done some looking around on the web and found that there are 3rd party extensions which support MacBinary, that will allow photo uploads. My question is, does it behoove me to go ahead and just use the asp and vb or should I go ahead and obtain the 3rd party extensions? My main concerns are security and being able to reach Mac users as well as PC users. I have never used a feature like this before and would just like some input before making a decision one way or the other. Thanks.
 
BTW, I am researching building pages that will allow one to upload photos to their server. My first sentence was a bit vague.
 
You do not need a third party application and it does not matter if the files are for Windows, Mac, Unix, iPhone, or Speak-N-Spell.

The reason is that, from the point of view of your server-side logic, all incomming files are just data sent from the browser that need to be written to the disk. Unless you add complexity, the pure ASP upload scripts will not attempt to process the file in any way.
 
Sheco,
When you say pure ASP... do you mean using strictly ASP with no other languages? If so, then the script I found here which uses VB may not be a good place to start? Thanks.
 
Actually ASP is not a language.

ASP is the default web application development platform for the IIS web service. ASP exposes a COM interface to IIS (Server object), to each web application (Application and Session objects), and to the individual HTML transactions between server and browser (Request and Response objects).

ASP has native support for VBScript and JavaScript but you can optionally install other script interpreters to allow you to use other languages for ASP.

That said, VBScript is the most commonly used language and most ASP example code you find will use it.

I believe that the script you found is a good place to start.
 
Sheco,
Ok. I just wanted to be sure before I started writing it, what you meant by pure ASP. I didn't want to start using VB with the ASP if you knew of another direction to point me to, strictly with ASP. I had read that ASP didn't support multipart form data and didn't think from first glance there was a way to use strictly ASP. But the more I visit this forum and continue to build this project, the more I learn and the more I realize I don't know (which is disheartening at times - money well spent right?)

I asked my supervisor if he knew what would be supported in terms of the server and he told me VB will be, so I thought I would start with that. Quite honestly, I used VB a lot when I was in school for this, so it is more of a comfort zone. Sorry for the terminology issue, but thanks for the info nonetheless. :) Thanks again for your help.
 
Personally, I prefer to use VBScript for writing the server-side logic and JavaScript for client-side code.

Not only is JavaScript supported on more browsers, but using a different coding syntax for client-side vs server-side gives me a visual clue that helps me keep it all straight in my head.
 
I used the code provided here and the code seemingly executes, but so far as I can tell it is not actually uploading the information. Here is the page that I believe gives the file paths for the information to be stored?

Code:
<%@ Language=VBScript %>
<%Option Explicit%>
<!-- #include file="upLoadFunctions.asp" -->
<%
' Create the FileUploader
Dim Uploader, File, FileSys, FilePath
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()

' Check if any files were uploaded

If Uploader.Files.Count = 0 Then
    Response.Write "File(s) not uploaded."
Else
    ' Loop through the uploaded files
    For Each File In Uploader.Files.Items
        
        ' Set upload Path and Filename to check if that file already exists
        FilePath = "C:\Inetpub\[URL unfurl="true"]wwwroot\aspdevelopment\photos\"&File.FileName[/URL]
        Set FileSys = CreateObject("Scripting.FileSystemObject")

        ' If intended uploaded file already exists in the specified directory do alert and redirect previous page
        If FileSys.FileExists(FilePath) then
            Response.Write("<script>alert('Sorry FileName:"& File.FileName &" Already Used!!  Please Rename Your Local File')</script>")
            Response.Write("<script>window.location.href='upLoadStart.asp'</script>")  
        else
            ' Else Save the file
            File.SaveToDisk "C:\\Inetpub\\[URL unfurl="true"]wwwroot\\aspdevelopment\\photos\\"[/URL]
        end if
    Next
    ' Confirm file saved and redirect to previous page if more files to be uploaded
    Response.Write("<script>alert('File Saved')</script>")  
    Response.Write("<script>window.location.href='upLoadStart.asp'</script>")  
End If

%>

~E
 
There are a number of recognised ASP uploaders on PSC. The fastest I have found is here:

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
johnwm... that was an excellent link/uploader. I was even able to find the actual place that it sent the file. Since you say you have used it, is there a way to have it save to a specific folder on the server? Or will it just automatically put it in root folder?

~E
 
You can put the uploaded file where you like. Look for
Code:
If FileName <> "" Then
					' we have a file, let's save it to disk
					strpath = Mid(Filename,InstrRev(FileName,"\")+1)

					[COLOR=red]FileName = "pics/news/" & Mid(Filename,InstrRev(FileName,"\")+1)[/color]
and add your path in the RED bit

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Thanks John... will give it a go.

~E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top