Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 24
  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2010
    Messaggi
    90

    modifica persist asp upload

    ciao a tutti,

    codice:
    <HTML>
    <HEAD>
    <TITLE>AspJpeg: da form a disco a db - in asp</TITLE>
    </HEAD>
    <BODY>
    
    
    <FORM ENCTYPE="multipart/form-data" METHOD="POST" ACTION="upload.asp">
    <TABLE CELLPADDING="3" CELLSPACING="0" BORDER="0" BGCOLOR="#EEEEEE">
    <TR><TD>Immagine:</TD><TD><INPUT TYPE=FILE NAME="MyFile"></TD></TR>
    <TR><TD>Dimensione anteprima:</TD><TD>
    <SELECT NAME="scale">
    <OPTION VALUE="75">75%
    <OPTION VALUE="50">50%
    <OPTION VALUE="25">25%
    <OPTION VALUE="10">10%
    </SELECT></TD></TR>
    
    <TR><TD>Descrizione:</TD><TD><TEXTAREA NAME="Description"></TEXTAREA></TD></TR>
    
    <TR><TD COLSPAN="2"><INPUT TYPE="SUBMIT" VALUE="Upload"></TD></TR>
    </TABLE>
    </FORM>
    
    </BODY>
    </HTML>
    codice:
    <HTML>
    <HEAD>
    <TITLE>AspJpeg </TITLE>
    </HEAD>
    <BODY>
    
    
    <%
    	' Create an instance of AspUpload object
    	Set Upload = Server.CreateObject("Persits.Upload")
    
    	' Compute path to save uploaded files to
    	Path = Server.MapPath("/public/")
    
    
    	' Capture uploaded file. Save returns the number of files uploaded
    	Count = Upload.Save(Path)
    
    	If Count = 0 Then
    		Response.Write "Scegli immagine. riprova."
    		Response.End
    	Else
    
    		' Obtain File object representing uploaded file
    		Set File = Upload.Files(1)
    
    		' Is this a valid image file?
    		If File.ImageType <> "UNKNOWN" Then
    
    			' create instance of AspJpeg object
    			Set jpeg = Server.CreateObject("Persits.Jpeg")
    			
    			' open uploaded file
    			jpeg.Open( File.Path )
    
    			' resize image accoring to "scale" option.
    			' notice that we cannot use Request.Form, so we use Upload.Form instead.
    			jpeg.Width = jpeg.OriginalWidth * Upload.Form("scale") / 100
    			jpeg.Height = jpeg.OriginalHeight * Upload.Form("scale") / 100
    
    			SavePath = Path & "\small_" & File.ExtractFileName
    
    			' AspJpeg always generates JPEG thumbnails regardless of original format.
    			' If the original file was not a JPEG, append .JPG extension.
    			If UCase(Right(SavePath, 3)) <> "JPG" Then
    				SavePath = SavePath & ".jpg"
    			End If
    
    			jpeg.Save SavePath
    
    			' Using ADO, save both images in the database along with description.
    			strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("/mdb-database/aspjpeg.mdb")
    
    			Set rs = Server.CreateObject("adodb.recordset")
    			rs.Open "images", strConnect, 1, 3
    			rs.AddNew
    			
    			' Use File.Binary to access binary data of uploaded file.
    			rs("original_image").Value = File.ExtractFileName
    
    			Set ThumbFile = Upload.OpenFile(SavePath)
    			rs("thumbnail").Value = "\small_" & File.ExtractFileName
    
    			rs("description") = Upload.Form("Description")
    
    			rs.Update
    			rs.Close
    			Set rs = Nothing
    
    			Response.Write "Fatto, sia il file originale che l'anteprima sono stati salvati nel database.
    
    "
    			Response.Write "una copia dei files è stata creata in cartella scelta dal webmaster "
    
    		Else			
    			Response.Write "Immagine non valida. riprova."
    			Response.End
    		End If
    	End If
    %>
    </BODY>
    </HTML>
    avrei la necessità di:
    - caricare con un solo campo input più immagini
    - nel db oltre nome del file, prima, mi metta il percorso del file (esempio: www.sito.it/public/cartella/img.jpg), questo sia per le anteprime che mi genera che per l'immagine grande
    - le antepeime in una cartella e le immagini grandi in un' altra

    é complicato?

    ma se vorrei inserire altri campi input dove vanno messi? (quello sono capace a farlo)

    Grazie mille in anticipo

  2. #2
    Amministratore L'avatar di Vincent.Zeno
    Registrato dal
    May 2003
    residenza
    Emilia-Romagna (tortellini und cappelletti land!)
    Messaggi
    20,812

    Re: modifica persist asp upload

    Originariamente inviato da matmilan
    avrei la necessità di:
    - caricare con un solo campo input più immagini
    - nel db oltre nome del file, prima, mi metta il percorso del file (esempio: www.sito.it/public/cartella/img.jpg), questo sia per le anteprime che mi genera che per l'immagine grande
    - le antepeime in una cartella e le immagini grandi in un' altra

    é complicato?

    ma se vorrei inserire altri campi input dove vanno messi? (quello sono capace a farlo)
    ricorda che sei tenuto, come tutti, ad utilizzare il tag [CODE][/CODE] per postare codice sul forum. grazie

    premetto che non ho nemmeno letto tutto il codice viste la tue domande,
    e tante domande in un'unico post non possono ottenere una risposta esauriente ed esemplificativa

    - scordatelo
    - perché? è una scelte strategica castrante
    - perché creare miniature quando si può fare un resize la volo?
    (anche per il resize c'è la sua guida, e puoi comunque salvare il risultato)
    - abbastanza, ma fattibile
    - la guida stessa di persits dice come mettere più input
    (a parte "se vorrei" che va segnato in rosso tre volte e un quarto d'ora sui ceci dietro alla lavagna )

  3. #3
    Utente di HTML.it
    Registrato dal
    Feb 2010
    Messaggi
    90
    scusa ero di fretta e mi sono dimenticato comunque grazie

    sistemo subito

    alternative per upload multiplo ce ne sono?

  4. #4
    Amministratore L'avatar di Vincent.Zeno
    Registrato dal
    May 2003
    residenza
    Emilia-Romagna (tortellini und cappelletti land!)
    Messaggi
    20,812
    Originariamente inviato da matmilan
    alternative per upload multiplo ce ne sono?
    se già usi persits (ottimo componente) che altro cerchi?

  5. #5
    Utente di HTML.it
    Registrato dal
    Feb 2010
    Messaggi
    90
    Il problema è che se si vuole caricare una quindicina/ventina di foto è scomodo caricarle una ad una

  6. #6
    Amministratore L'avatar di Vincent.Zeno
    Registrato dal
    May 2003
    residenza
    Emilia-Romagna (tortellini und cappelletti land!)
    Messaggi
    20,812

    Re: Re: modifica persist asp upload

    Originariamente inviato da Vincent.Zeno
    - la guida stessa di persits dice come mettere più input
    occhio al timeout

  7. #7
    Utente di HTML.it
    Registrato dal
    Feb 2010
    Messaggi
    90
    Sono riuscito a fare tutto io a parte l'upload.
    Alternative? idee?
    Non so proprio come fare l'upload multiplo

    codice:
    <HTML>
    <HEAD>
    <TITLE>AspJpeg </TITLE>
    </HEAD>
    <BODY>
    
    
    <%
    	' Create an instance of AspUpload object
    	Set Upload = Server.CreateObject("Persits.Upload")
    
    	' Compute path to save uploaded files to
    	Path = Server.MapPath("PERCORSO1")
    	Path1 = Server.MapPath("PERCORSO2")
    
    
    	' Capture uploaded file. Save returns the number of files uploaded
    	Count = Upload.Save(Path)
    
    	If Count = 0 Then
    		Response.Write "Scegli immagine. riprova."
    		Response.End
    	Else
    
    		' Obtain File object representing uploaded file
    		Set File = Upload.Files(1)
    
    		' Is this a valid image file?
    		If File.ImageType <> "UNKNOWN" Then
    
    			' create instance of AspJpeg object
    			Set jpeg = Server.CreateObject("Persits.Jpeg")
    			
    			' open uploaded file
    			jpeg.Open( File.Path )
    
    			' resize image accoring to "scale" option.
    			' notice that we cannot use Request.Form, so we use Upload.Form instead.
    			jpeg.Width = jpeg.OriginalWidth * Upload.Form("scale") / 100
    			jpeg.Height = jpeg.OriginalHeight * Upload.Form("scale") / 100
    
    			SavePath = Path1 & "\small-" & File.ExtractFileName
    
    			' AspJpeg always generates JPEG thumbnails regardless of original format.
    			' If the original file was not a JPEG, append .JPG extension.
    			If UCase(Right(SavePath, 3)) <> "JPG" Then
    				SavePath = SavePath & ".jpg"
    			End If
    
    			jpeg.Save SavePath
    
    			' Using ADO, save both images in the database along with description.
    			strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("/mdb-database/foto.mdb")
    
    			Set rs = Server.CreateObject("adodb.recordset")
    			rs.Open "images", strConnect, 1, 3
    			rs.AddNew
    			
    			' Use File.Binary to access binary data of uploaded file.
    			rs("original_image").Value = "PERCORSO1" & File.ExtractFileName
    
    			Set ThumbFile = Upload.OpenFile(SavePath)
    			rs("thumbnail").Value = "PERCORSO2" & "/small-" & File.ExtractFileName
    
    			rs("description") = Upload.Form("Description")
    
    			rs.Update
    			rs.Close
    			Set rs = Nothing
    
    			Response.Write "Fatto, sia il file originale che l'anteprima sono stati salvati nel database.
    
    "
    			Response.Write "una copia dei files è stata creata in cartella scelta dal webmaster "
    
    		Else			
    			Response.Write "Immagine non valida. riprova."
    			Response.End
    		End If
    	End If
    %>
    </BODY>
    </HTML>

  8. #8
    Amministratore L'avatar di Vincent.Zeno
    Registrato dal
    May 2003
    residenza
    Emilia-Romagna (tortellini und cappelletti land!)
    Messaggi
    20,812
    ops...
    ero convinto che quell'esempio fosse anche sul sito ufficiale
    qui nel vademecum dovrebbe esserci ancora, se non c'è dimmelo che te lo riporto
    http://vademecum.aruba.it/start/Persits/index.asp

  9. #9
    Utente di HTML.it
    Registrato dal
    Feb 2010
    Messaggi
    90
    me lo riporti per favore che non lo trovo?

  10. #10
    Utente di HTML.it
    Registrato dal
    Feb 2010
    Messaggi
    90
    sono riuscito con l'upload multiplo ma a farlo così sono obbligato ad usare tutti i campi input.
    E' facile da risolvere?

    codice:
    <%
     		Set Upload = Server.CreateObject("Persits.Upload")
    				
     		Path = Server.MapPath("/public/foto")
    		Path1 = Server.MapPath("/public/thumbs")
    
    		Count = Upload.Save(Path)
    		
    		If Count = 0 Then
    			Response.redirect "errore.asp"
    			Response.End
    		Else
    
    		Set File1 = Upload.Files("MyFile1") 
    		Set File2 = Upload.Files("MyFile2")
    		Set File3 = Upload.Files("MyFile3") 
    		Set File4 = Upload.Files("MyFile4")
    		Set File5 = Upload.Files("MyFile5") 
    		Set File6 = Upload.Files("MyFile6")
    		Set File7 = Upload.Files("MyFile7") 
    		Set File8 = Upload.Files("MyFile8")
    		Set File9 = Upload.Files("MyFile9") 
    		Set File10 = Upload.Files("MyFile10")
    		Set File11 = Upload.Files("MyFile11") 
    		Set File12 = Upload.Files("MyFile12")
    			
    		If File1.ImageType = "JPEG" or  File1.ImageType = "PNG" or File1.ImageType = "JPG" or File2.ImageType = "JPEG" or  File2.ImageType = "PNG" or File2.ImageType = "JPG" or File3.ImageType = "JPEG" or  File3.ImageType = "PNG" or File3.ImageType = "JPG" or File4.ImageType = "JPEG" or  File4.ImageType = "PNG" or File4.ImageType = "JPG" or File5.ImageType = "JPEG" or  File5.ImageType = "PNG" or File5.ImageType = "JPG" or File6.ImageType = "JPEG" or  File6.ImageType = "PNG" or File6.ImageType = "JPG" or File7.ImageType = "JPEG" or  File7.ImageType = "PNG" or File7.ImageType = "JPG" or File8.ImageType = "JPEG" or  File8.ImageType = "PNG" or File8.ImageType = "JPG" or File9.ImageType = "JPEG" or  File9.ImageType = "PNG" or File9.ImageType = "JPG" or File10.ImageType = "JPEG" or  File10.ImageType = "PNG" or File10.ImageType = "JPG" or File11.ImageType = "JPEG" or  File11.ImageType = "PNG" or File11.ImageType = "JPG" or File12.ImageType = "JPEG" or  File12.ImageType = "PNG" or File12.ImageType = "JPG" Then
    
    		Set jpeg1 = Server.CreateObject("Persits.Jpeg")
    		Set jpeg2 = Server.CreateObject("Persits.Jpeg")
    		Set jpeg3 = Server.CreateObject("Persits.Jpeg")
    		Set jpeg4 = Server.CreateObject("Persits.Jpeg")
    		Set jpeg5 = Server.CreateObject("Persits.Jpeg")
    		Set jpeg6 = Server.CreateObject("Persits.Jpeg")
    		Set jpeg7 = Server.CreateObject("Persits.Jpeg")
    		Set jpeg8 = Server.CreateObject("Persits.Jpeg")
    		Set jpeg9 = Server.CreateObject("Persits.Jpeg")
    		Set jpeg10 = Server.CreateObject("Persits.Jpeg")
    		Set jpeg11 = Server.CreateObject("Persits.Jpeg")
    		Set jpeg12 = Server.CreateObject("Persits.Jpeg")
    
    		jpeg1.Open( File1.Path )
    		jpeg2.Open( File2.Path )
    		jpeg3.Open( File3.Path )
    		jpeg4.Open( File4.Path )
    		jpeg5.Open( File5.Path )
    		jpeg6.Open( File6.Path )
    		jpeg7.Open( File7.Path )
    		jpeg8.Open( File8.Path )
    		jpeg9.Open( File9.Path )
    		jpeg10.Open( File10.Path )
    		jpeg11.Open( File11.Path )
    		jpeg12.Open( File12.Path )
    
    		jpeg1.Width = 65
    		jpeg1.Height = 65
    
    		jpeg2.Width = 65
    		jpeg2.Height = 65
    		
    		jpeg3.Width = 65
    		jpeg3.Height = 65
    
    		jpeg4.Width = 65
    		jpeg4.Height = 65
    		
    		jpeg5.Width = 65
    		jpeg5.Height = 65
    
    		jpeg6.Width = 65
    		jpeg6.Height = 65
    		
    		jpeg7.Width = 65
    		jpeg7.Height = 65
    
    		jpeg8.Width = 65
    		jpeg8.Height = 65
    		
    		jpeg9.Width = 65
    		jpeg9.Height = 65
    
    		jpeg10.Width = 65
    		jpeg10.Height = 65
    		
    		jpeg11.Width = 65
    		jpeg11.Height = 65
    
    		jpeg12.Width = 65
    		jpeg12.Height = 65
    
    		SavePath1 = Path1 & "\small_" & File1.ExtractFileName
    		SavePath2 = Path1 & "\small_" & File2.ExtractFileName
    		SavePath3 = Path1 & "\small_" & File3.ExtractFileName
    		SavePath4 = Path1 & "\small_" & File4.ExtractFileName
    		SavePath5 = Path1 & "\small_" & File5.ExtractFileName
    		SavePath6 = Path1 & "\small_" & File6.ExtractFileName
    		SavePath7 = Path1 & "\small_" & File7.ExtractFileName
    		SavePath8 = Path1 & "\small_" & File8.ExtractFileName
    		SavePath9 = Path1 & "\small_" & File9.ExtractFileName
    		SavePath10 = Path1 & "\small_" & File10.ExtractFileName
    		SavePath11 = Path1 & "\small_" & File11.ExtractFileName
    		SavePath12 = Path1 & "\small_" & File12.ExtractFileName
    		
    		If UCase(Right(SavePath1, 3)) <> "JPG" Then
    			SavePath1 = SavePath1 & ".jpg"
    		End If
    		
    		If UCase(Right(SavePath2, 3)) <> "JPG" Then
    			SavePath2 = SavePath2 & ".jpg"
    		End If
    				
    		If UCase(Right(SavePath3, 3)) <> "JPG" Then
    			SavePath3 = SavePath3 & ".jpg"
    		End If
    		
    		If UCase(Right(SavePath4, 3)) <> "JPG" Then
    			SavePath4 = SavePath4 & ".jpg"
    		End If		
    		If UCase(Right(SavePath5, 3)) <> "JPG" Then
    			SavePath5 = SavePath5 & ".jpg"
    		End If
    		
    		If UCase(Right(SavePath6, 3)) <> "JPG" Then
    			SavePath6 = SavePath6 & ".jpg"
    		End If
    				
    		If UCase(Right(SavePath7, 3)) <> "JPG" Then
    			SavePath7 = SavePath7 & ".jpg"
    		End If
    		
    		If UCase(Right(SavePath8, 3)) <> "JPG" Then
    			SavePath8 = SavePath8 & ".jpg"
    		End If
    				
    		If UCase(Right(SavePath9, 3)) <> "JPG" Then
    			SavePath9 = SavePath9 & ".jpg"
    		End If
    		
    		If UCase(Right(SavePath10, 3)) <> "JPG" Then
    			SavePath10 = SavePath10 & ".jpg"
    		End If		
    		
    		If UCase(Right(SavePath11, 3)) <> "JPG" Then
    			SavePath11 = SavePath11 & ".jpg"
    		End If
    		
    		If UCase(Right(SavePath12, 3)) <> "JPG" Then
    			SavePath12 = SavePath12 & ".jpg"
    		End If
    		
    		jpeg1.Save SavePath1
    		jpeg2.Save SavePath2
    		jpeg3.Save SavePath3
    		jpeg4.Save SavePath4
    		jpeg5.Save SavePath5
    		jpeg6.Save SavePath6
    		jpeg7.Save SavePath7
    		jpeg8.Save SavePath8
    		jpeg9.Save SavePath9
    		jpeg10.Save SavePath10
    		jpeg11.Save SavePath11
    		jpeg12.Save SavePath12
    		
    
    		strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("/mdb-database/db.mdb")
    		
    		Set rs = Server.CreateObject("adodb.recordset")
    		rs.Open "images", strConnect, 1, 3
    		rs.AddNew
    		
    		rs("original_image").Value = "percorso" & File1.ExtractFileName
    		rs("thumbnail").Value = "percorso" & "/small_" & File1.ExtractFileName
    		rs("autore") = Upload.Form("autore")
    		rs("events") = Upload.Form("events")
    		
    		rs.AddNew
    		
    		rs("original_image").Value = "percorso" & File2.ExtractFileName
    		rs("thumbnail").Value = "percorso" & "/small_" & File2.ExtractFileName
    		rs("autore") = Upload.Form("autore")
    		rs("events") = Upload.Form("events")
    
    		rs.AddNew
    				
    		rs("original_image").Value = "percorso" & File3.ExtractFileName
    		rs("thumbnail").Value = "percorso" & "/small_" & File3.ExtractFileName
    		rs("autore") = Upload.Form("autore")
    		rs("events") = Upload.Form("events")
    		
    		rs.AddNew
    		
    		rs("original_image").Value = "percorso" & File4.ExtractFileName
    		rs("thumbnail").Value = "percorso" & "/small_" & File4.ExtractFileName
    		rs("autore") = Upload.Form("autore")
    		rs("events") = Upload.Form("events")
    
    		rs.AddNew				
    
    		rs("original_image").Value = "percorso" & File5.ExtractFileName
    		rs("thumbnail").Value = "percorso" & "/small_" & File5.ExtractFileName
    		rs("autore") = Upload.Form("autore")
    		rs("events") = Upload.Form("events")
    		
    		rs.AddNew
    		
    		rs("original_image").Value = "percorso" & File6.ExtractFileName
    		rs("thumbnail").Value = "percorso" & "/small_" & File6.ExtractFileName
    		rs("autore") = Upload.Form("autore")
    		rs("events") = Upload.Form("events")
    
    		rs.AddNew
    
    		rs("original_image").Value = "percorso" & File7.ExtractFileName
    		rs("thumbnail").Value = "percorso" & "/small_" & File7.ExtractFileName
    		rs("autore") = Upload.Form("autore")
    		rs("events") = Upload.Form("events")
    		
    		rs.AddNew
    		
    		rs("original_image").Value = "percorso" & File8.ExtractFileName
    		rs("thumbnail").Value = "percorso" & "/small_" & File8.ExtractFileName
    		rs("autore") = Upload.Form("autore")
    		rs("events") = Upload.Form("events")
    
    		rs.AddNew
    				
    		rs("original_image").Value = "percorso" & File9.ExtractFileName
    		rs("thumbnail").Value = "percorso" & "/small_" & File9.ExtractFileName
    		rs("autore") = Upload.Form("autore")
    		rs("events") = Upload.Form("events")
    		
    		rs.AddNew
    		
    		rs("original_image").Value = "percorso" & File10.ExtractFileName
    		rs("thumbnail").Value = "percorso" & "/small_" & File10.ExtractFileName
    		rs("autore") = Upload.Form("autore")
    		rs("events") = Upload.Form("events")
    		
    		rs.AddNew
    		
    		rs("original_image").Value = "percorso" & File11.ExtractFileName
    		rs("thumbnail").Value = "percorso" & "/small_" & File11.ExtractFileName
    		rs("autore") = Upload.Form("autore")
    		rs("events") = Upload.Form("events")
    
    		rs.AddNew
    				
    		rs("original_image").Value = "percorso" & File12.ExtractFileName
    		rs("thumbnail").Value = "percorso" & "/small_" & File12.ExtractFileName
    		rs("autore") = Upload.Form("autore")
    		rs("events") = Upload.Form("events")
    		
    		rs.Update
    		rs.Close
    		Set rs = Nothing
    
            response.redirect "fatto.asp"
    
    	Else			
    		Response.redirect "errore.asp"
    		Response.End
    	End If
    End If
    %>

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 © 2026 vBulletin Solutions, Inc. All rights reserved.