Link to home
Start Free TrialLog in
Avatar of cryptoboy
cryptoboy

asked on

file.path error

Hi,

I have an upload script based on ASPUPLOAD and ASPJPEG. 2 files must be uploaded. An mp3 file and an image file. If the file is an image I would like to resize it. I use the following code but get a  file path error :

Persits.Jpeg.1 error '800a0002'

The system cannot find the path specified.

/Uploadnewkol_alpha1.asp, line 76

Can someone see whats wrong?

Best regards Theo DK

<%

    dag = Day(Date)
    mdr = Month(Date)
    aar = Year(Date)
    ctime = Hour(Time)
    min = Minute(Time)
    sek = Second(Now)

TIDNU = aar & mdr & dag & ctime & min & sek

function lavPassword(antal)
  tilladtkarakter = "abcdefghijklmnopqrstuvwxyz1234567890"
  str = "" 
  randomize
  for j = 1 to antal
    index = Int(rnd * len(tilladtkarakter))+1
    str = str & Mid(tilladtkarakter,index,1)
  next
  lavPassword = str
end function
Set Upload = Server.CreateObject("Persits.Upload.1")
Upload.ProgressID = Request.QueryString("PID")
'Upload.SetMaxSize 3000000, True
CountFiles = Upload.Save
if CountFiles < 2 then response.redirect "uploadfform_alfa_lot1.asp?message=Du skal have valgt en lydfil og 1 billede med gennemse"
i=1
Recordset1.addnew
for each file in Upload.files
fn  = lcase(Right(File.ExtractFileName, 4))
imageerror="uploadfform_alfa_lot1.asp?message=Du må kun uploade billeder af typen .gif eller .jpg og lydfiler af typen .mp3"
if imageerror <> "" then
Ext = lcase(Right(File.ExtractFileName, 3))
If not (Ext = "gif" or Ext = "jpg" or Ext = "mp3") Then
file.Delete
Response.Redirect imageerror
End If
End if
descr=Upload.Form("descr" & i)
filnavn=Upload.Form("pic" & i)
check=Upload.Form("check" & i)
          if check = "-1" then
  check = "-1"
else
  check = "0"
end if

filnavn = Session("MM_Username") & TIDNU & lavpassword(5) & fn
If file.ImageType <> "UNKNOWN" Then

    ' Create instance of AspJpeg object
          set Jpeg = Server.CreateObject("Persits.Jpeg")
    ' Open uploaded file /this is the error line 76
    Jpeg.Open (file.Path)
' New width
L = 400
' Resize, preserve aspect ratio
Jpeg.Width = L
Jpeg.Height = Jpeg.OriginalHeight * L / Jpeg.OriginalWidth
' create thumbnail and save it to disk
Jpeg.SaveAs "d:\Inetpub\wwwroot\putandtake\alfa\media\" & filnavn
else
File.SaveAs "d:\Inetpub\wwwroot\putandtake\alfa\media\" & filnavn
end if
Recordset1("filnavn" & i)="media/" & filnavn
Recordset1("Descr" & i)=descr
Recordset1("check" & i)=check
i=i+1
next
bruger=Upload.Form("bruger")
niveau=Upload.Form("niveau")
bem=Upload.Form("bem")
titel=Upload.Form("titel")
typen=Upload.Form("type")
Recordset1("user")=bruger
Recordset1("niveau")=niveau
Recordset1("bem")=bem
Recordset1("titel")=titel
Recordset1("type")=typen
Recordset1.update
response.redirect "uploadfform_alfa_lot1.asp?message=" & Countfiles & " fil(er) blev uploadet til serveren !"
 %>
ASKER CERTIFIED SOLUTION
Avatar of Steven_Inter
Steven_Inter

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
Avatar of cryptoboy
cryptoboy

ASKER

Hi Steven,

That helped a lot : You see the file.path is still from my machine (not uploaded) and looks like this : E:\tjspliff\nytmemoryumagepar\4_appelsin.jpg

Should I rearrange the code and how?
File.SaveAs "d:\Inetpub\wwwroot\putandtake\alfa\media\" & filnavn
If file.ImageType <> "UNKNOWN" Then
    ' Create instance of AspJpeg object
          set Jpeg = Server.CreateObject("Persits.Jpeg")
    ' Open uploaded file
    Jpeg.Open (file.Path)
      'Response.Write "<BR>" & file.Path & "<BR>"
'Response.End
' New width
L = 503
' Resize, preserve aspect ratio
Jpeg.Width = L
Jpeg.Height = Jpeg.OriginalHeight * L / Jpeg.OriginalWidth
' create thumbnail and save it to disk
Jpeg.Save ("d:\Inetpub\wwwroot\putandtake\alfa\media\" & filnavn)
end if

This works for me. Is it allright ?
Anyway, I really appreciate your input. The response.end is really useful and works like break; in JS or ? Never used it before but will from now on. Thanks again from Theo.
Without seeing exactly what the code is doing its hard to give an answer, other than to say, if it works the way you wanted it to, then it can't be too bad.

As for Response.End, that's exactly what it does.  It stops any further posts to the screen.  Very, very useful thing to know.

Glad I was of some help, cheers for the points.