Link to home
Start Free TrialLog in
Avatar of franse
franse

asked on

Upload en generate thumbnail goes wrong.

Hello Expert,

I 've build a script that uses Persits ASPUpload to upload a file to aupload dir. It works fine but now I like the script to generate a thumbnail as well. I use ASPImage for this.

I've got to use these components. My profider forces me to.

I've tested the thumbnail script and it works fine
I've tested the upload script and it works fine

But together they produce an error:
---------------error------------------
The following error occured while uploading:
"Object required"
Please try again.
-------------end error----------------

My question is how can I combine both scripts. Where does the makethumb script has to be put to make both work?

Both scripts can be found at the end of this posting,

Thanks,

Franse

----------------------------upload script----------------------------------------------------
!--#INCLUDE FILE="Settings.asp"-->

%
dim RelationId
RelationId = request.cookies("RealtionId")
%>
%

' Persits ASPUpload instellingen
      Set Upload = Server.CreateObject("Persits.Upload.1")
      
      Upload.OverwriteFiles = False
      On Error Resume Next

      Upload.SetMaxSize 1048576      ' Limit files to 1MB
      Count = Upload.Save(Server.Mappath(UploadPath))

%>

HTML>
BODY background=".\..\oudpapier1.jpg">
CENTER>

% If Err > 0 Then %>

      FONT SIZE=3 FACE="Arial" COLOR=#0020A0>
      H3>The following error occured while uploading:/h3>
      /FONT>

      FONT SIZE=3 FACE="Arial" COLOR=#FF2020>
      h2>"% = Err.Description %>"/h2>
      /FONT>

      FONT SIZE=2 FACE="Arial" COLOR="#0020A0">
      Please A HREF="http://www.aspupload.com/livedemo.asp">try again/A>.
      /FONT>

% Else %>
FONT SIZE=3 FACE="Arial" COLOR=#0020A0>
h2>Het is gelukt het bestand is ge-upload./h2>
/FONT>

FONT SIZE=3 FACE="Arial" COLOR=#0020A0>
TABLE BORDER=1 CELLPADDING=3 CELLSPACING=0>
TD>B>Bestand:/B>/TD>
% If Count > 0 Then %>
      %
      Set File = Upload.Files(1)
      If File.ImageType = "GIF" or File.ImageType = "JPG" or File.ImageType = "PNG" Then %>
            TD ALIGN=CENTER>IMG SRC="/upload/% = File.FileName%>" style="ZOOM: 50%">BR>% = File.OriginalPath%>BR>
            (% = File.ImageWidth %> x % = File.ImageHeight %> pixels)
            /TD>
      % Else %>
            TD>% = File.OriginalPath %>/TD>
      % End If %>
%            
dim cnn,rst
set cnn = Server.CreateObject("ADODB.Connection")
set rst = Server.CreateObject("ADODB.RecordSet")
cnn.Open "driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath(DBPath)
sqltext = "SELECT * FROM FileUpload"
rst.Open sqltext,cnn,3,3
rst.AddNew
rst("Beschrijving") = Upload.Form("Description")
rst("Catagorie") = Upload.Form("Catagorie")
rst("Publicatie") = Upload.Form("Publicatie")
rst("Bestandsnaam") = File.FileName
rst("Extentie") = File.Ext
rst("RelationId") = RelationId
rst.update
If IsObject(rst) Then
If Not rst Is Nothing Then
   If rst.State > 0 Then
      rst.Close
   End If
   Set rst = Nothing
End If
End If

If IsObject(CNN) Then
If Not CNN Is Nothing Then
   If CNN.State > 0 Then
      CNN.Close
   End If
   Set CNN = Nothing
End If
End If            
%>

% Else %>
      TD>File not selected./TD>
% End If %>
TR>
TD>B>Description:/B>/TD>TD>% = Upload.Form("Description") %> /TD>TR>
TD>B>Categories:/B>/TD>
TD>
%
      For Each Item in Upload.Form
            If Item.Name = "Category" Then Response.Write Item.Value & "BR>"
      Next
%>
 /TD>
/TABLE>
/FONT>
P>
FONT SIZE=3 FACE="Arial" COLOR=#0020A0>
LET OP! Het bestand zal niet direct beschikbaar komen. Ik zal het kopelen aan een persoon (onderwerp) uit de stamboom en daarna kunt u het terug vinden in de site. Ik stuur u een mailtje wanneer het bestand online komt met daarin vermeld waar u het terug kan vinden.



FONT SIZE=2 FACE="Arial" COLOR=#0020A0>
Klik hier A HREF="Form.asp">here/A> om nog meer bestanden te uploaden.
/FONT>
% End If %>
/CENTER>
/BODY>
/HTML>
----------------------------------------end of upload script-------------------------------------------------------------------------------

----------------------------------------makethumb script part---------------------------------------------
%
' ASPImage instellingen
      Set Image = Server.CreateObject("AspImage.Image")
      Image.LoadImage(Server.MapPath(Uploadpath & "\" & File.FileName))      
      Image.FileName = Server.MapPath(Thumbpath & "\" & File.FileName)
      Image.ImageFormat = 1
      Image.JPEGQuality = 70
      Image.Resize 150,188
      Image.SaveImage
      Set Image = Nothing      
%>
----------------------------------------end of makethumb script----------------------------------------------
ASKER CERTIFIED SOLUTION
Avatar of xanderd
xanderd

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial