Vi prego Aiutatemi.......
Sono nuovo del forum e ho un enorme problema che non so come fare a risolvere.....
Ho recuperato da internet, uno script asp che mi permette di uplodare un file.....
Esserndo riuscito nel contesto a far funzionare uno script, ho un problema che non so come risolvere...
Voglio che lo script mi cambi i nomi dei file come da record gia inserito in database e richiamato tramite recordser asp.Questo è il codice della pagina principale
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
option explicit
Response.Expires = -1
Server.ScriptTimeout = 600
%>
<%
Dim Recordset1ultimo
Dim Recordset1ultimo_numRows
Set Recordset1ultimo = Server.CreateObject("ADODB.Recordset")
Recordset1ultimo.ActiveConnection = MM_db1_STRING
Recordset1ultimo.Source = "SELECT max(Cod_Art) as massimo FROM Barche"
Recordset1ultimo.CursorType = 0
Recordset1ultimo.CursorLocation = 2
Recordset1ultimo.LockType = 1
Recordset1ultimo.Open()
Recordset1ultimo_numRows = 0
%>
<%
' ************************************************** **
' Change the value of the variable below to the pathname
' of a directory with write permissions, for example "C:\Inetpub\wwwroot"
Dim uploadsDirVar
uploadsDirVar = Server.mappath("/public")
' ************************************************** **
' Note: this file uploadTester.asp is just an example to demonstrate
' the capabilities of the freeASPUpload.asp class. There are no plans
' to add any new features to uploadTester.asp itself. Feel free to add
' your own code. If you are building a content management system, you
' may also want to consider this script: http://www.webfilebrowser.com/
function OutputForm()
%>
<form name="frmSend" method="POST" enctype="multipart/form-data" action="Inserisci2.asp" onSubmit="return onSubmitForm();">
File 1: <input name=attach1 type=file size=35>
File 2: <input name=attach2 type=file size=35>
File 3: <input name=attach3 type=file size=35>
File 4: <input name=attach4 type=file size=35>
<input style="margin-top:4" type=submit value="Upload">
</form>
<%
end function
function TestEnvironment()
Dim fso, fileName, testFile, streamTest
TestEnvironment = ""
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FolderExists(uploadsDirVar) then
TestEnvironment = "Folder " & uploadsDirVar & " does not exist.
The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."
exit function
end if
fileName = uploadsDirVar & "\test.txt"
on error resume next
Set testFile = fso.CreateTextFile(fileName, true)
If Err.Number<>0 then
TestEnvironment = "Folder " & uploadsDirVar & " does not have write permissions.
The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."
exit function
end if
Err.Clear
testFile.Close
fso.DeleteFile(fileName)
If Err.Number<>0 then
TestEnvironment = "Folder " & uploadsDirVar & " does not have delete permissions, although it does have write permissions.
Change the permissions for IUSR_computername on this folder."
exit function
end if
Err.Clear
Set streamTest = Server.CreateObject("ADODB.Stream")
If Err.Number<>0 then
TestEnvironment = "The ADODB object Stream is not available in your server.
Check the Requirements page for information about upgrading your ADODB libraries."
exit function
end if
Set streamTest = Nothing
end function
function SaveFiles
Dim Upload, fileName, fileSize, ks, i, fileKey
Set Upload = New FreeASPUpload
Upload.Save(uploadsDirVar)
SaveFiles = ""
ks = Upload.UploadedFiles.keys
if (UBound(ks) <> -1) then
SaveFiles = "File Caricato con Successo: "
for each fileKey in Upload.UploadedFiles.keys
SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) "
next
else
SaveFiles = "The file name specified in the upload form does not correspond to a valid file in the system."
end if
end function
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Upload File Immagine</title>
<script>
function onSubmitForm() {
var formDOMObj = document.frmSend;
if (formDOMObj.attach1.value == "" )
alert("Please press the browse button and pick a file.")
else
return true;
return false;
}
</script>
</HEAD>
<BODY>
[img]../Immagini/Banner.jpg[/img]
<div style="border-bottom: #A91905 2px solid;font-size:16">Upload File Imbarcazione </div>
<%
Dim diagnostics
if Request.ServerVariables("REQUEST_METHOD") <> "POST" then
diagnostics = TestEnvironment()
if diagnostics<>"" then
response.write "<div style=""margin-left:20; margin-top:30; margin-right:30; margin-bottom:30;"">"
response.write diagnostics
response.write "
Per correggere il Problema, Ricarica la Pagina."
response.write "</div>"
else
response.write "<div style=""margin-left:150"">"
OutputForm()
response.write "</div>"
end if
else
response.write "<div style=""margin-left:150"">"
OutputForm()
response.write SaveFiles()
response.write "
</div>"
end if
%>
<div style="border-top: #A91905 2px solid;font-size:10">
<p align="center">Torna in Redazione</p>
[img]../Immagini/Under.jpg[/img]</p>
</div>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
</body>
</html>
<%
Recordset1ultimo.Close()
Set Recordset1ultimo = Nothing
%>
Praticamente,così funziona, ma mi fa l'upload del file esattamente come è il file originale....
Vorrei che il file venisse rinominato tramite questa stringa
1° File
"Recordset1ultimo.Fields.Item("massimo").Value & ".jpg"
2° File
"Recordset1ultimo.Fields.Item("massimo").Value & "_1.jpg"
3° File
"Recordset1ultimo.Fields.Item("massimo").Value & "_2.jpg"
4° File
"Recordset1ultimo.Fields.Item("massimo").Value & "_3.jpg"
Vi Prego Aiutatemi....
Ho anche msn all'indirizzo clio2006@hotmail.it

Rispondi quotando