Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

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:
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,



----------------------------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))


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

% If Err > 0 Then %>

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

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

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

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

FONT SIZE=3 FACE="Arial" COLOR=#0020A0>
% 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)
      % 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("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
If IsObject(rst) Then
If Not rst Is Nothing Then
   If rst.State > 0 Then
   End If
   Set rst = Nothing
End If
End If

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

% Else %>
      TD>File not selected./TD>
% End If %>
TD>B>Description:/B>/TD>TD>% = Upload.Form("Description") %> /TD>TR>
      For Each Item in Upload.Form
            If Item.Name = "Category" Then Response.Write Item.Value & "BR>"
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.
% End If %>
----------------------------------------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
      Set Image = Nothing      
----------------------------------------end of makethumb script----------------------------------------------
1 Solution
Is there a form on which a user has a file browser input to select their image file?

If so then check if it uses an encoding type of multipart/form data:

<form action="" method="post" enctype="multipart/form-data" name="form2">

and for the thumbnail script, there is no form encoding.

You will get 'object required' if you try to submit the image file with the wrong form encoding, or if you try to pass the image on as a 'variable' to another page before upload is complete - the thumbnail script for example.

So you should 'forget' about the thumbnail script for now, and just upload the image, as a seperate step.

Then, only when the upload is completed do you activate the resize script on the server.

Hope this helps...

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now