FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old April 20th, 2004, 06:01 AM
Captain Planet's Avatar
Captain Planet Captain Planet is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 328 Captain Planet User rank is Lance Corporal (50 - 100 Reputation Level)Captain Planet User rank is Lance Corporal (50 - 100 Reputation Level)Captain Planet User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Day 14 h 15 m 15 sec
Reputation Power: 5
FTP files of a certain type!!

Hi folks. I have the following function which saves uploaded files (where path is the path to upload to):

Public Sub Save(path)
Dim streamFile, fileItem

if Right(path, 1) <> "\" then path = path & "\"
if not uploadedYet then Upload
For Each fileItem In UploadedFiles.Items
if fileItem.Length > 30000 then
else
Set streamFile = Server.CreateObject("ADODB.Stream")

streamFile.Type = 1
streamFile.Open
StreamRequest.Position=fileItem.Start
StreamRequest.CopyTo streamFile, fileItem.Length
streamFile.SaveToFile path & fileItem.FileName, 2
streamFile.close
Set streamFile = Nothing
fileItem.Path = path & fileItem.FileName

end if
Next
End Sub

The trouble is, I want users only to be able to upload files of a certain type, eg jpg's. I tried adding the following code.....

if (fileItem.FileName.GetExtensionName(path & fileItem.FileName) = "jpg") then


but I get the error:Object required: 'fileItem.FileNam'

I know why the error occurs, but don't know how to solve the problem!!

Any help would be much appreciated!
__________________
Captain Planet.

Reply With Quote
  #2  
Old April 20th, 2004, 05:46 PM
Doug G Doug G is online now
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,715 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 12 m 41 sec
Reputation Power: 688
Apparently you are not inserting the check line of code in the Save sub.
__________________
======
Doug G
======
"Hide, hide witch! The good folk come to burn thee. Their keen enjoyment hid behind their gothic mask of duty." -Mark Clifton

Reply With Quote
  #3  
Old April 21st, 2004, 07:04 AM
Captain Planet's Avatar
Captain Planet Captain Planet is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 328 Captain Planet User rank is Lance Corporal (50 - 100 Reputation Level)Captain Planet User rank is Lance Corporal (50 - 100 Reputation Level)Captain Planet User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Day 14 h 15 m 15 sec
Reputation Power: 5
Cheers Doug (tho not sure what you meant??)
For anyone who has this problem in the future, I solved it. Here's the code.


Code:
	
	Public Sub Save(path)
		Dim streamFile,originName,fileItem, fileType, sSplit


		if Right(path, 1) <> "\" then path = path & "\"

			if not uploadedYet then Upload

			For Each fileItem In UploadedFiles.Items
			if fileItem.Length > 30000 then
			else
				originName = fileItem.FileName
				'filter off the path to get the actual file name ("\")
				If Len(originName) > 0 Then
					sSplit = split(originName, "\")
					fileType = sSplit(ubound(sSplit))
					Set sSplit = Nothing
					If Instr(fileType, ".") = 0 Then 'If there is no file extension
			     		fileType = ".doc"
					Else
					    'filter off the file name to get the file type (".")
					     sSplit = split(fileType, ".")
					     fileType = sSplit(ubound(sSplit))
					     fileType = "." & LCase(fileType)
					     Set sSplit = Nothing
					End If

					If filetype = ".doc" Or filetype = ".xls" Or filetype = ".pdf" Or filetype = ".rtf" Or filetype = ".htm" Or filetype = ".html" Or filetype = ".txt" Or filetype = ".gif" Or filetype = ".jpg" Then
                     'Response.Write filetype
						Set streamFile = Server.CreateObject("ADODB.Stream")

						streamFile.Type = 1
						streamFile.Open

						StreamRequest.Position=fileItem.Start
						StreamRequest.CopyTo streamFile, fileItem.Length
						streamFile.SaveToFile path & fileItem.FileName, 2
						streamFile.close
						Set streamFile = Nothing
						fileItem.Path = path & fileItem.FileName

					 end if

				end if
			end if
		Next
	End Sub




Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > FTP files of a certain type!!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway