file.path error

Posted on 2006-04-28
Last Modified: 2008-01-09

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 = ""
  for j = 1 to antal
    index = Int(rnd * len(tilladtkarakter))+1
    str = str & Mid(tilladtkarakter,index,1)
  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"
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
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"
  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
File.SaveAs "d:\Inetpub\wwwroot\putandtake\alfa\media\" & filnavn
end if
Recordset1("filnavn" & i)="media/" & filnavn
Recordset1("Descr" & i)=descr
Recordset1("check" & i)=check
response.redirect "uploadfform_alfa_lot1.asp?message=" & Countfiles & " fil(er) blev uploadet til serveren !"
Question by:cryptoboy
    LVL 2

    Accepted Solution

    Made it hard for me to see that error... :-)

    Ok, what I would do is response.write the line:
    Response.Write "<BR>" & file.Path & "<BR>"

    Paste that into your code above line 76.  This will at least show you where the web browser is trying to get to.

    If there shouldn't be any problem with what is posted back to the screen, ie, the URL file.Path brings back is correct.  Then you will have yourself a permissions issue.  You would need to make the path that the URL is trying to access, Web User Permissions.  Either share the folder over the web, or allow permissions for IUSR_MachineName to access that path.

    if the file path starts with: "../"  you may want to make sure that IIS allows virtual paths to be passed.

    Let me know what the response.write brings back.

    Author Comment

    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?

    Author Comment

    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>"
    ' 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 ?

    Author Comment

    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.
    LVL 2

    Expert Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Adobe Dreamweaver CC 2015

    Adobe Dreamweaver Creative Cloud is used by web designers and front-end developers and allows you to visualize your site in real-time as you code. This course covers exam objectives for the Adobe Certified Associate (ACA) certification.

    I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
    Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now