Salve a tutti vi chiedo scusa se chiedo qualcosa di già trattato, ma non sto capendo più niente, allora ho creato una sezione per aggiunge news con diversi campi di testo e fin qui tutto bene, adesso vorrei aggiungere insieme alla news una o più foto e salvala in una cartella del server ed il collegamento alla foto nel database, ho letto nel forum della classe di baol74, ma sto avendo un po’ di problemi per integrarla alla pagina news.asp che si occupa di ricevere i dati dal form ed inviale al database. Il primo errore era dovuto al Request.Form che usavo per inserire i dati del db, lo cambiato con oUpload.Form come viene dette in questo messagio http://forum.html.it/forum/showthrea...to+classe+baol e adesso ho questo errore
Errore di run-time di Microsoft VBScript error '800a01a8'
Necessario oggetto: 'Files'
/nome_cartella/upload.asp, riga 989
Codice upload.asp
Dove sbaglio?codice:Riga 988 Public Property Get EOF() Riga 989 EOF = Files.EOF Riga 990 end property
Grazie a tutti
Codice pagina invio dati a news.asp
Codice pagina news.aspcodice:<form method="POST" action="News_DB.asp?tipo=aggiungi" language="javascript"> <table border="0" cellpadding="4" cellspacing="8" class="tableface_agg"> <tr> <td width="22%"><font face="Verdana" size="2">Titolo news: *</font></td> <td width="78%"><font face="Verdana" size="2"><% Dim sBasePath sBasePath = Request.ServerVariables("PATH_INFO") sBasePath = Left( sBasePath, InStrRev( sBasePath, "/_samples" ) ) Dim oFCKeditor Set oFCKeditor = New FCKeditor oFCKeditor.BasePath = sBasePath oFCKeditor.Width = "100%" oFCKeditor.Height = "120" oFCKeditor.Value = "" oFCKeditor.Create "titolo" %> </textarea> </font></td> </tr> <tr> <td width="22%"><font face="Verdana" size="2">Descrizione Breve: *</font></td> <td width="78%"> <% sBasePath = Request.ServerVariables("PATH_INFO") sBasePath = Left( sBasePath, InStrRev( sBasePath, "/_samples" ) ) Set oFCKeditor = New FCKeditor oFCKeditor.BasePath = sBasePath oFCKeditor.Width = "100%" oFCKeditor.Height = "250" oFCKeditor.Value = "" oFCKeditor.Create "descrizione" %> </td> </tr> <tr> <td width="22%"><font face="Verdana" size="2">Contenuto news: *</font></td> <td width="78%"> <% sBasePath = Request.ServerVariables("PATH_INFO") sBasePath = Left( sBasePath, InStrRev( sBasePath, "/_samples" ) ) Set oFCKeditor = New FCKeditor oFCKeditor.BasePath = sBasePath oFCKeditor.Width = "100%" oFCKeditor.Height = "350" oFCKeditor.Value = "" oFCKeditor.Create "contenuto" %> </td> </tr> <tr> <td width="22%"><font face="Verdana" size="2">Alteprima: </font></td> <td width="78%"><INPUT TYPE="file" NAME="image0"></td> </tr> <tr> <td width="22%"><font face="Verdana" size="2">Categoria news: *</font></td> <td width="78%"> <% Do While iRecordsShown < iPageSize And Not RecSet.EOF numero = numero + 1 %><font><input type=radio name="categoria" value="<%=RecSet("categoriaName")%>"><%=RecSet("categoriaName")%></font> <% iRecordsShown = iRecordsShown + 1 RecSet.MoveNext Loop %> </td> </tr> <tr> <td width="22%"><font face="Verdana" size="2">Autore News: *</font></td> <td width="78%"> <% sBasePath = Request.ServerVariables("PATH_INFO") sBasePath = Left( sBasePath, InStrRev( sBasePath, "/_samples" ) ) Set oFCKeditor = New FCKeditor oFCKeditor.BasePath = sBasePath oFCKeditor.Width = "100%" oFCKeditor.Height = "120" oFCKeditor.Value = "" oFCKeditor.Create "autore" %> </td> </tr> <tr> <td width="100%" colspan="2"><font face="Verdana" size="2"><input type="submit" value="Aggiungi news" name="B1"><input type="reset" value="Reimposta" name="B2"></font> </td> </tr> <tr><td><h3 class="title_obb">* Campi obbligatori</h3></td></tr> </table> </form>
codice:<% IF Session("Loggato") = False and Session("Username") = "" then Response.Redirect "../index.asp" End IF %> <% Dim oUpload Set oUpload= new cUpload With oUpload 'La riga seguente impoosta la connessione al database e la tabella di inserimento dati 'La connesione e la tabella verranno aperti con il metodo oUpload.Database.Open() .SetDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath("/nome_cartella/mdb-database/db.mdb"),"SELECT Top 1 * FROM news" .EnabledAspUpload = False .EnabledImageSize = False .EnabledLog = False .AutoRename = True .Overwrite = False .SetPath "ps_images\" .Load .MoveFirst if .EOF then NumFiles = .Count() Response.write "0 Files caricati su " & NumFiles &" : controlla le dimensioni e il tipo di file." else .Database.Open() While Not .EOF .Save response.Write "il file " & .GetFileName &" è stato salvato " 'Inserimento dei valori .Database.Fields("nome") = .Form("nome") .Database.Fields("image0") = .GetCompletePathFile 'Inserimento .Database.AddNew() .MoveNext Wend end if End With Set oUpload = Nothing %> <% IF Len(Request("autore")) = 0 or Len(Request("titolo")) = 0 or Len(Request("contenuto")) = 0 or Len(Request("descrizione")) = 0 or Len(Request("categoria")) = 0 then %> <h2 class="error">Errore: Campi non Compilati!</h2> <% Else operazione = Request.QueryString("tipo") Set RecSet = Server.CreateObject("ADODB.Recordset") IF operazione = "aggiungi" then SQL = "SELECT * FROM NEWS" else SQL = "SELECT * FROM NEWS WHERE ID = " & Request.Querystring("id") &"" End IF RecSet.Open SQL, Conn, adOpenStatic, adLockOptimistic IF operazione = "aggiungi" then RecSet.Addnew RecSet("ora") = time() RecSet("data") = date() RecSet("now") = now() End IF RecSet("titolo") = Replace(oUpload.Form("titolo"), "'", "′") RecSet("autore") = Replace(oUpload.Form("autore"), "'", "′") RecSet("categoriaName") = Replace(oUpload.Form("categoria"), "'", "′") RecSet("categoriaID") = Replace(oUpload.Form("categoria"), "'", "′") RecSet("descrizione") = Replace(Replace(oUpload.Form("descrizione"), chr(13), " "), "'", "′") RecSet("contenuto") = Replace(Replace(oUpload.Form("contenuto"), chr(13), " "), "'", "′") RecSet.Update RecSet.Close Set RecSet = Nothing %> <h3 class="title">Operazione eseguita correttamente!</h3> <% End IF Conn.Close Set Conn = Nothing %>

Rispondi quotando