?
Solved

file.path error

Posted on 2006-04-28
5
Medium Priority
?
1,305 Views
Last Modified: 2008-01-09
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 !"
 %>
0
Comment
Question by:cryptoboy
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
Steven_Inter earned 1000 total points
ID: 16560403
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>"
Response.End

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.
0
 

Author Comment

by:cryptoboy
ID: 16560455
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?
0
 

Author Comment

by:cryptoboy
ID: 16561591
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 ?
0
 

Author Comment

by:cryptoboy
ID: 16568021
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.
0
 
LVL 2

Expert Comment

by:Steven_Inter
ID: 16568790
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.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

829 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