![]() |
| |||||||
| Sponsored Links |
![]() | « Previous Thread | Next Thread » |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| ||||
| ||||
| Hi All, I have a form that when the submit button is clicked, it will insert the form data to sql table and also upload files to server folder and also send an email. I have this all in one function.... first is select statment with insert statement then uploads files if applicable then sends email i'm not sure if i should have all this in one function or if I need more if statements or error handling. problem 1 - if i enter form fields that havent been entered but i have the same file name that has already been submitted...i do get a message about the file has already been submitted and it can't be overwritten(this is good)...but it still adds the form fields to the database and sends out an email...how/where can I prevent it from adding since the file name is the same? problem 2 - if i enter something that has already been entered, i do get message about it can't be submitted (this is good), but it still allows file upload and send emails.... ![]() It should only send an email when a new form (not been entered) and valid files (not already uploaded). Thanks for any direction with this. |
| Sponsored Links |
|
#2
| ||||
| ||||
| something on the order of this should work Code: If file_name exists then error message Else upload file select statement if exists delete file error message else insert statement send email end if end if
__________________ Quote of the Month: Regret: It hurts to admit when you make mistakes - but when they're big enough, the pain only lasts a second. Questions to Ponder: Could it be that all those trick-or-treaters wearing sheets aren’t going as ghosts but as mattresses? iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm") copyright © 2008 sbenj69 |
|
#3
| ||||
| ||||
| Thanks for your help Mehere! ![]() I got the email part fixed now with your help but still having issue with the top part....I think because the part with the error is in the other aspfile. Is there a way in javascript to check if filename already exist on server and stop it there? like i do when there is no eq # entered. |
|
#4
| ||||
| ||||
| not that i'm aware of. what i usually do is upload the document/file and add a datetime stamp to the filename, that way, it's hard to have 2 doucments with the same name. |
|
#5
| ||||
| ||||
| i think i follow...you already helped me with that part where if i try to upload a file with the same name it won't overwrite it. i need to figure out if the form fields are filled out with new data that hasn't been entered but the file field(s) do already exist, don't add to database. I can't get it to stop adding the record. i thought maybe adding the file field(s) to the select statement might help but it doesn't totally cause then it stops it even when i do have new form data and a new file. ..lol. Okies...I'll keep seeing what I can do here. Thanks for your replies. |
|
#6
| ||||
| ||||
| Quote:
so you mean, if i upload a file name myform.doc, then you add it to the database and server as myform_Date_time.doc? Thanks! |
|
#7
| ||||
| ||||
| i have a function that creates a unique date/time stamp. like so: Code: function uniqueStamp(strDate)
Dim strUnique
strUnique = datepart("m",strDate) & datepart("d",strDate) & datepart("h",strDate) & datepart("n",strDate) & datepart("s",strDate)
uniqueStamp = strUnique
end function
Code: thisFile = split(fileName,".") strFile = thisFile(0) & "_" & uniqueStamp(now()) & "." & thisFile(1) Code: Dim fso
set fso=CreateObject("Scripting.FileSystemObject")
fso.CopyFile Server.MapPath(fileName), Server.MapPath(strFile)
|
|
#8
| ||||
| ||||
| Hi Mehere, I've got it adding the new name with date/time info in it to the database but having problem with the uploaded file...can't get it to rename with the new name. here is what i have so far....i put the copyfile line (blue) but doesn't seem to do anything: Code: for each fileKey in Upload.UploadedFiles.keys
thisFile = split(Upload.UploadedFiles(fileKey).FileName,".")
strFile1 = strFile1 & thisFile(0) & "_" & uniqueStamp(now()) & "." & thisFile(1) & ","
next
if FileName <> "" then
strFile1 = left(strFile1,len(strFile1)-1) 'this will remove the trailing comma
end if
if strFile <> "" then
set oFSO = Server.CreateObject("Scripting.FileSystemObject")
if oFSO.FileExists(uploadsDirVar & "/" & strFile) then
oFSO.MoveFile uploadsDirVar & "\" & strFile, Server.MapPath("/Files") & "\" & strFile
oFSO.CopyFile Server.MapPath("/Files") & "\" & strFile, Server.MapPath("/Files") & "\" & strFile1
end if
set oFSO = nothing
end if
strSQL = "Select 1 from tblTestTable where Equipment = '" & strEQNumber & "'"
Set rs = Conn.Execute(strSQL)
if rs.eof and rs.bof then
if inStr(strFile1,",") > 0 then
arrFile = split(strFile1,",")
blnArray = 1
end if
if blnArray = 1 then
SQL Insert statements....
|
|
#9
| ||||
| ||||
| try this: Code: oFSO.MoveFile uploadsDirVar & "\" & strFile, uploadsDirVar & "\" & strFile1 |
| The Following User Says Thank You to mehere For This Useful Post: | ||
Rebelle (October 13th, 2008) | ||
|
#10
| ||||
| ||||
| Hi Mehere, ok...i was able to now get a value for my strFile that i was missing...so this one holds the original filename and strFile1 holds the new name with date/time info. still having an issue though...i still can't get it to change/rename/move my original file to rename to the new file name. ![]() when i try this, error on line-file not found: Code: oFSO.MoveFile uploadsDirVar & "\" & strFile, uploadsDirVar & "\" & strFile1 Code: oFSO.MoveFile Server.MapPath("/Files") & "\" & strFile, Server.MapPath("/Files") & "\" & strFile1
Thanks for any suggestions! |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|