Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    upload baol -- piu files in diverse cartelle --

    Ciao a tutti,

    dopo due giorni di ricerca e lettura post su questo forum sono riuscito a usare la fantastica clase di baol....

    ora sto provando a fare una cosa un tantino più complicata...
    fare l'uload di più file, i quali devono andare in diverse cartelle, e aggiornare dei campi di un database:

    posto il codice che funziona per aggirnamento campi db e upload dei file tutti nel paht specificato:

    codice:
     <% 	  
    If Request("Upload")="1" then
    	Dim oUpload
    Set oUpload = new cUpload
    With oUpload
    .SetDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath("/mdb-database/lasercut.mdb"),"SELECT * FROM products"
    .EnabledImageSize = TRUE
    .SetPath "/mdb-database/db_documents/images/faq/"
    .Load
    .UploadOnly "Images"
    .MoveFirst
    .Database.open()
    While Not .Eof
    If .Files("Height")>150 or .Files("Width")>150  then
    	 Response.write ("<span class=""intestazioni"">LE DIMENSIONI DELL'IMMAGINE </span> <span class=""intestazioni"">" &_
    	 .GetFileName() &"</span> <span class=""intestazioni"">
    NON SONO CORRETTE</span> <span class=""intestazioni"">(" &_
    	 .Files("Height") &"x" & .Files("Width") &")</span>: <span class=""intestazionired"">Immagine non caricata!</span>
    
    "  )
    	Test = False
    else
    	  .Save 
    	  filename = .GetFileName()
    	  Test = True
    
    end if
    .MoveNext
    Wend
    'Spiegazione di questa if: inserirai i dati nel db solo se entrambe le foto hanno una dimensione corretta e se entrambe sono state caricate.
    If Test  then
      '.Database.Fields("idfaq") = .Form("fidnews")
      .Database.Fields("anno") = .Form("fyear")
      .Database.Fields("title") = .Form("ftitle")
      .Database.Fields("description") = .Form("fdescription")
      .Database.Fields("ldescription") = .Form("fldescription")
      .Database.Fields("idcategoria") = .Form("fcategory")
      .Database.Fields("image") =  filename 
      .Database.Addnew
      response.write "<span class=""intestazioni"">"
      response.write ("AGGIUNTA FAQ CON IMMAGINE RIUSCITA!")
      response.write "</span>"
      
    elseif test = false  and .form("campo1") = "" then
       '.Database.Fields("idnews") = .Form("fidnews")
      .Database.Fields("data") = .Form("fdata")
      .Database.Fields("title") = .Form("ftitle")
      .Database.Fields("description") = .Form("fdescription")
      .Database.Fields("text") = .Form("ftext")
      .Database.Addnew
      response.write "<span class=""intestazioni"">"
      response.write ("LA FAQ  E' STATA INSERITA CORRETTAMENTE! 
     L'IMMAGINE NON E' STATA INSERITA POICHE' SI E' SCELTO DI NON CARICARE ALCUNA IMMAGINE CON QUESTA FAQ!")
      response.write "</span>"
      
    else
    end if
    End With
    Set oUpload = Nothing
    end if
     %>
    Qualcuno può aiutarmi a rendere dinamico il paht e far si che ogni uno dei 4 file che ho nella form vengono uploadati in dir differenti.

    grazie

  2. #2
    Utente di HTML.it L'avatar di fiber81
    Registrato dal
    Oct 2002
    Messaggi
    328
    oUpload.SetPath "../Public/"

    oUpload.Files("DestPath") = oUpload.Files("DestPath") & "sotto percorso"

    Forse questo ti può aiutare, io in questo modo a seconda dell'estensione cambio percorso
    Ci sono 10 tipi di persone al mondo, quelli che conoscono la numerazione binaria e quelli che non la conoscono!

  3. #3
    Utente di HTML.it L'avatar di fiber81
    Registrato dal
    Oct 2002
    Messaggi
    328
    prima del save potresti fare una cosa del genere
    codice:
    If .Files("InputName") = "CAMPO1" Then
    .Files("DestPath") = .Files("DestPath") & "dir1/" 
    .Save
    ElseIf .Files("InputName") = "CAMPO2" Then
    .Files("DestPath") = .Files("DestPath") & "dir2/" 
    .Save
    ElseIf .Files("InputName") = "CAMPO3" Then
    .Files("DestPath") = .Files("DestPath") & "dir3/" 
    .Save
    ElseIf .Files("InputName") = "CAMPO4" Then
    .Files("DestPath") = .Files("DestPath") & "dir4/" 
    .Save
    End If
    Se non sbalio ad ogni ciclo DestPath viene risettato a SetPath, quindi puoi cambiarlo senza ricordarti il percorso precedente, comunque prova!
    Ci sono 10 tipi di persone al mondo, quelli che conoscono la numerazione binaria e quelli che non la conoscono!

  4. #4
    ..grazie tanto...della risposta ...sono alle prime armi con ASP...
    non mi è chiaro la serie di IF...e il tuo primo post...devo inserirli entrambi?

    Ti spiego meglio le mie esigenze....
    devo salvare tutti e 4 file in diverse dir, e poi il loro nome deve aggiornare 4 campi di un db, assieme ad altri data che inserisco in una form....

  5. #5
    grazie funziona con i tui suggerimenti e dopo un pò di studio....

    riporto tutto il codice magari può essere d'aiuto a qualcun altro:


    codice:
    Dim oUpload
    Set oUpload = new cUpload
    With oUpload
    .SetDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath("mio.mdb"),"SELECT * FROM products"
    .EnabledImageSize = TRUE
    .SetPath "/db_documents/" 'parte fissa
    .Load
    '.UploadOnly "Images"
    .MoveFirst
    .Database.open()
    While Not .Eof
    
    If .Files("InputName") = "imagesmall" Then
    .Files("DestPath") = .Files("DestPath") & "images/products/small/" 
    	If .Files("Height")>100 or .Files("Width")>100  then 
       		Response.write ("<span class=""intestazioni"">LE DIMENSIONI DELL'IMMAGINE </span> <span class=""intestazioni"">" &_
    	   .GetFileName() &"</span> <span class=""intestazioni"">
    NON SONO CORRETTE</span> <span class=""intestazioni"">(" &_
    	   .Files("Height") &"x" & .Files("Width") &")</span>: <span class=""intestazionired"">Immagine non caricata!</span>
    
    "  )
    	   nouploadimages = True
     	Else
    		.Save
        	filenameimgs = .GetFileName() 
    	End If  
    
    ElseIf .Files("InputName") = "image" and nouploadimages = False  Then
    .Files("DestPath") = .Files("DestPath") & "images/products/"
    .Save
    filenameimg = .GetFileName()   
    ElseIf .Files("InputName") = "broscure" and nouploadimages = False  Then
    .Files("DestPath") = .Files("DestPath") & "pdf/" 
    .Save
    filenamebr = .GetFileName()
    ElseIf .Files("InputName") = "tdata" and nouploadimages = False Then
    .Files("DestPath") = .Files("DestPath") & "technicaldata/" 
    .Save
    filenametd = .GetFileName()
    End If
    	 
    .MoveNext
    Wend
    'Spiegazione di questa if.
    If nouploadimages = False and .form("image") <> "" then
      .Database.Fields("anno") = .Form("fyear")
      .Database.Fields("title") = .Form("ftitle")
      .Database.Fields("description") = .Form("fdescription")
      .Database.Fields("ldescription") = .Form("fldescription")
      .Database.Fields("idcategoria") = .Form("fcategory")
      .Database.Fields("image") =  filenameimg 
      .Database.Fields("imagesmall") =  filenameimgs 
      IF filenametd <> "" Then
      	.Database.Fields("technicaldurl") =  filenametd
      Else
      	.Database.Fields("technicaldurl") =  "no_tchnical_data.htm"
    	notd = true
      End If
      IF filenamebr <> "" Then
      	.Database.Fields("broscureurl") =  filenamebr 
      Else
      	.Database.Fields("broscureurl") =  "no_broscure.htm"
    	nobr = true
      End If	
      .Database.Addnew
      IF notd = False and nobr= False then
      response.write "<span class=""intestazioni"">"
      response.write ("AGGIUNTA PRODOTTO CON IMMAGINI, BROSCURE E TECHNICAL DATA RIUSCITO!")
      response.write "</span>"
      Else
        If notd and nobr then
    	 response.write "<span class=""intestazioni"">"
      	 response.write ("AGGIUNTA PRODOTTO CON IMMAGINI RIUSCITO! HAI DECISO DI NON CARICARE LA PAGINA TECHNICAL DATA E LA PAGINA BROSCURE PER QUESTO PRODOTTO! ")
      	 response.write "</span>"
    	 else
      	 If notd then
      		response.write "<span class=""intestazioni"">"
      		response.write ("AGGIUNTA PRODOTTO CON IMMAGINI E BROSCURE RIUSCITO! HAI DECISO DI NON CARICARE LA PAGINA TECHNICAL DATA PER QUESTO PRODOTTO! ")
      		response.write "</span>"
         End IF
         If nobr then
       		response.write "<span class=""intestazioni"">"
      		response.write ("AGGIUNTA PRODOTTO CON IMMAGINI E TECHNICAL DATA RIUSCITO! HAI DECISO DI NON CARICARE LA PAGINA BROSCURE PER QUESTO PRODOTTO! ")
      		response.write "</span>"
         End IF
    	End IF
       End IF
    Else 
    
      response.write "<span class=""intestazioni"">"
      response.write ("IL PRODOTTO NON E' STATO AGGIUNTO! PERCHE LE IMMAGINI SONO RICHIESTE!")
      response.write "</span>"
      
    end if
    End With
    Set oUpload = Nothing

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.