?
Solved

Upload en generate thumbnail goes wrong.

Posted on 2003-03-21
1
Medium Priority
?
204 Views
Last Modified: 2012-08-14
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----------------------------------------------
0
Comment
Question by:franse
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
xanderd earned 135 total points
ID: 8181556
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...
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question