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 = "abcdefghijklmnopqrstuvwxy z123456789 0"
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("Persi ts.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=D u skal have valgt en lydfil og 1 billede med gennemse"
i=1
Recordset1.addnew
for each file in Upload.files
fn = lcase(Right(File.ExtractFi leName, 4))
imageerror="uploadfform_al fa_lot1.as p?message= Du må kun uploade billeder af typen .gif eller .jpg og lydfiler af typen .mp3"
if imageerror <> "" then
Ext = lcase(Right(File.ExtractFi leName, 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("Persi ts.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\putand take\alfa\ media\" & filnavn
else
File.SaveAs "d:\Inetpub\wwwroot\putand take\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")=nivea u
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 !"
%>
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 = "abcdefghijklmnopqrstuvwxy
str = ""
randomize
for j = 1 to antal
index = Int(rnd * len(tilladtkarakter))+1
str = str & Mid(tilladtkarakter,index,
next
lavPassword = str
end function
Set Upload = Server.CreateObject("Persi
Upload.ProgressID = Request.QueryString("PID")
'Upload.SetMaxSize 3000000, True
CountFiles = Upload.Save
if CountFiles < 2 then response.redirect "uploadfform_alfa_lot1.asp
i=1
Recordset1.addnew
for each file in Upload.files
fn = lcase(Right(File.ExtractFi
imageerror="uploadfform_al
if imageerror <> "" then
Ext = lcase(Right(File.ExtractFi
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("Persi
' 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\putand
else
File.SaveAs "d:\Inetpub\wwwroot\putand
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")=nivea
Recordset1("bem")=bem
Recordset1("titel")=titel
Recordset1("type")=typen
Recordset1.update
response.redirect "uploadfform_alfa_lot1.asp
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
File.SaveAs "d:\Inetpub\wwwroot\putand take\alfa\ media\" & filnavn
If file.ImageType <> "UNKNOWN" Then
' Create instance of AspJpeg object
set Jpeg = Server.CreateObject("Persi ts.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\putan dtake\alfa \media\" & filnavn)
end if
This works for me. Is it allright ?
If file.ImageType <> "UNKNOWN" Then
' Create instance of AspJpeg object
set Jpeg = Server.CreateObject("Persi
' 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\putan
end if
This works for me. Is it allright ?
ASKER
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.
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.
ASKER
That helped a lot : You see the file.path is still from my machine (not uploaded) and looks like this : E:\tjspliff\nytmemoryumage
Should I rearrange the code and how?