Ver Mensaje Individual
  #7 (permalink)  
Antiguo 06/06/2009, 12:39
Avatar de Wasper
Wasper
 
Fecha de Ingreso: julio-2006
Ubicación: de cai, picha!!!
Mensajes: 1.030
Antigüedad: 18 años, 9 meses
Puntos: 41
Respuesta: ASPJPEG y Godaddy

Hola Myakire, he leido sobre eso, al final me he instalado en mi ordenador local el ASPJPEG y ASPUPLOAD para hacer las pruebas en local... he estado trasteando con los ejemplos que trae, pero ahora me encuentro otro problema...

Resulta que he encontrado un buen ejemplo que hace lo que quiero, ademas se mete en base de datos las imagenes (aunque no me interesa eso) total he desmenuzado el codigo y consigo que en local eliges una imagen para subir y le dices que % quieres reducirla, cuando le das al subir, te sube en una carpeta la original y la redimensionada. Bien el problema esta cuando lo prueba en mi hosting, que me da error 500 pero no me dice nada mas... y claro mareado que estoy... he pensado que puede ser por el Server.Mappath("")... de todas formas te pongo el codigo por si ves algo que no veo yo...

Código:
<HTML>
<HEAD>
<TITLE>Subida ASP imagenes redimensionadas</TITLE>
</HEAD>
<BODY>

<!-- this script is invoked by form.asp-->
<%
	' Create an instance of AspUpload object
	Set Upload = Server.CreateObject("Persits.Upload")

	' Compute path to save uploaded files to
	Path = Server.MapPath("/images/") 


	' Capture uploaded file. Save returns the number of files uploaded
	Count = Upload.Savevirtual(Path)

	If Count = 0 Then
		Response.Write "No images selected. <A HREF=""03_form.asp"">Try again</A>."
		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("db/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.Binary

			Set ThumbFile = Upload.OpenFile(SavePath)
			rs("thumbnail").Value = ThumbFile.Binary

			rs("description") = Upload.Form("Description")

			rs.Update
			rs.Close
			Set rs = Nothing

			Response.Write "Success! Both the original file and its thumbnail are saved in the database.<P>"
			Response.Write "Copies can be found at <B>" & Path & "\" & File.ExtractFileName & "</B> and <B>" & SavePath & "</B>"

		Else			
			Response.Write "This is not a valid image. <A HREF=""formulario.asp"">Try again</A>."
			Response.End
		End If
	End If
%>
</BODY>
</HTML>
Muchas gracias

Saludos, Jose