Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 14

Discussione: problema con l'upload

  1. #1
    Utente di HTML.it L'avatar di xdjack
    Registrato dal
    May 2011
    Messaggi
    10

    problema con l'upload

    salve a tutti é la prima volta che posto nel forum cmq io ho un problema con questo codice:

    codice:
    
    <%@LANGUAGE="VBSCRIPT" %>
    <%
    Server.ScriptTimeOut = 10000
    %>
    
    <%
    IF(Session("id") = "" OR Session("key") = "") Then
    Response.Redirect("/default.asp?login=fail")
    Else
    Dim Upload
    Dim FileName
    Dim Folder
    Dim Ext
    Dim FileOK
    
    Set Upload = New clsUpload
    
    ' Grab file extension
    Ext = Upload.Fields("File1").FileExt
    
    ' Check to see if file extension is valid
    Select Case Ext
    	Case "GIF", "PNG", "JPG"
    		FileOK = True
    	Case Else
    		FileOK = False
    End Select
    
    ' If file was not valid
    If Not FileOK Then
    	
    	' Notify user of error
    	Response.Redirect("/ProfileEdit.asp?update=wrongFile")
    	
    	' Stop all execution after this line.
    	Response.End
    
    End If 
    
    DIM con
    		SET con = Server.CreateObject("ADoDB.Connection")
    		con.Provider ="Microsoft.JET.OLEDB.4.0"
    		con.open Server.MapPath("/db/users.mdb")
    		Set rs = Server.CreateObject("adodb.recordset")
            rs.open"SELECT * FROM tUtenti WHERE utente_user='"& Session("id") &"'"& _
            " AND utente_password='"& Session("key")&"'",con,2,3
            IF NOT(rs.EoF) Then
            dim fso,ts
            set fso = Server.CreateObject("Scripting.FileSystemObject")
            if (fso.FileExists(Server.MapPath("\pictures\" & rs.Fields("imagePath")))) Then  
            Set ts = fso.GetFile(Server.MapPath("\pictures\" & rs.Fields("imagePath")))
            ts.Delete
            set fso = Nothing
            End IF
    
    Randomize
    dim rd
    rd = (20000002 - 100000) * RND + 100000
    ' Grab the file name
    FileName = Upload.Fields("File1").FileName
    FileName = Replace(FileName," " , "_")
    FileName = Replace(FileName,".","_")
    FileName = FileName &"_" & rd & "." & Ext
    ' Get path to save file to
    
    Folder = Server.MapPath("/pictures") & "\"
    ' Save the binary data to the file system
    Upload("File1").SaveAs Folder & FileName 
    
    ' Release upload object from memory
    Set Upload = Nothing
    Session("P_True") = FileName  'to send the image path in the session var
    'to keep the picture in the database
    		rs.Fields("imagePath").value = TRIM(Session("P_True"))
    		rs.Update
            rs.close
     		set rs = nothing 
     		con.close
     		set con = Nothing
     		Session("editProf") = "sucess"
    		Response.Redirect("/ProfileEdit.asp")
        Else
        Session("editProf") = "fail"
        Response.Redirect("/ProfileEdit.asp")
        End IF
    	End IF
    %>
    la parte evidenziata é in pratica l'errore ma in teoria dovrebbe essere esatta
    JK

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Qual'è l'errore che ottieni?
    Fatti stampare quella stringa.
    La cartella pictures deve avere i permessi di scrittura.

    Roby

  3. #3
    Utente di HTML.it L'avatar di xdjack
    Registrato dal
    May 2011
    Messaggi
    10

    ecco l'errore

    ecco l'errore:


    Server.MapPath() error 'ASP 0173 : 80004005'

    Carattere non valido nel percorso

    /make/uploader/EditUpload.asp, riga 50

    Il parametro Path del metodo MapPath contiene un carattere non valido.
    JK

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    codice:
    response.write("\pictures\" & rs.Fields("imagePath"))
    response.end
    Guarda cosa ti scrive.

    Roby

  5. #5
    Utente di HTML.it L'avatar di xdjack
    Registrato dal
    May 2011
    Messaggi
    10
    quando salvo mi appare questa finestra(allegata)
    Immagini allegate Immagini allegate
    JK

  6. #6
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Il nome dell'immagine contiene una virgola??
    Prova ad invertire lo slash da \ a /

    Roby

  7. #7
    Utente di HTML.it L'avatar di xdjack
    Registrato dal
    May 2011
    Messaggi
    10
    le ho cambiate tutte e due dopo ho usato le altre combinazioni non cambia niente
    cmq il nome é dato in automatico quando carico l'immagine e cmq la virgola nel nome c'é
    JK

  8. #8
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,134
    Originariamente inviato da xdjack
    ... cmq il nome é dato in automatico quando carico l'immagine e cmq la virgola nel nome c'é
    Ma il problema è la virgola nel nome che non deve esserci.
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  9. #9
    Utente di HTML.it L'avatar di xdjack
    Registrato dal
    May 2011
    Messaggi
    10
    credo di aver capito allora il problema con l'upload é finito ora il problema persiste nel codice seguente che si chiama salva.asp


    codice:
    <HTML>
    <BODY>
    <%
    Set Upload = Server.CreateObject("Persits.Upload")
    On Error Resume Next
    Upload.Save(Server.MapPath("pictures/temp"))  'to save the file in our temporary file for first 
     
                                                  'time, that we can use the upload form mehtod against request form
    dim typ
    typ = Upload.Files("File1").ImageType   'to check if the file is not in the jpg/gif or png format
    if(typ <> "jpg" AND typ <> "JPG" AND typ <> "GIF" AND typ <> "gif" AND typ <> "PNG" AND typ <> "png") Then
    For Each File in Upload.Files
    		File.Delete
    		Next
    Response.Redirect("makeProfile.asp?ok=wrongFile")
    'response.write("File format = "& typ)
    End IF
    Session("pic") = (Upload.Files("File1").FileName)  'to get the file name in the sessino object
    'Response.write(Session("pic"))  check to get the name of the file in our session object
    'Response.End     closing testing to print the name
    dim fname,lname,emailsho,nickname,country,email,hobbies,aboutme,sex,key
    fname = Trim(Upload.Form("fname"))
    lname = Trim(Upload.Form("lname"))
    sex = Trim(Upload.Form("sex"))
    emailsho = Trim(Upload.Form("sho"))
    key = Trim(Upload.Form("key"))
    nickname = Trim(Upload.Form("nickname"))
    country = Trim(Upload.Form("country"))
    email = Trim(Upload.Form("email"))
    hobbies = Trim(Upload.Form("hobbies"))
    aboutme = Trim(Upload.Form("aboutme"))
    dim chk
    IF(emailsho = "ON") Then
    chk = true
    Else
    chk = false
    End IF
    
    IF(fname = "" OR lname = "" OR sex = "" OR key = "" OR nickname = "" _
    OR country = "" OR email = "" OR hobbies = "" OR aboutme = "") then
    For Each File in Upload.Files
    		File.Delete
    		Next
    Response.Redirect("makeProfile.asp?ok=emptyFields")
    Response.End
    End IF
    
    dim fileName,rn, NewFil,extn
    	  Randomize
    	  rn =(987654321 - 12345678) * RND + 1234567
    	  fileName = Trim(Session("pic"))
    	  NewFil = Replace(fileName," ","")
    	  NewFil = Replace(NewFil,".","-")
    	  extn = Replace(fileName," ","")
    	  NewFil = NewFil &"_"& rn &"_"& extn
    	  DIM con, rs, fs, ts
    
    		SET con = Server.CreateObject("ADoDB.Connection")
    		con.Provider ="Microsoft.JET.OLEDB.4.0"
    		con.open Server.MapPath("record/userInfo.mdb")
    		Set rs = Server.CreateObject("adodb.recordset")
    		
    		rs.Open "SELECT * FROM tUtenti WHERE utente_user='"& nickname &"'"&" OR utente_email='"& email &"'",con,2,3
    	If rs.EOF Then
    		set fs = Server.CreateObject("Scripting.FileSystemObject")
    	  If(fs.FileExists(Server.MapPath("pictures/temp/" & fileName))) Then
    	  	fs.MoveFile Server.MapPath("pictures/temp/"& fileName), Server.MapPath("pictures/" & NewFil)
    	    Set fs = Nothing
    	  End If
    		rs.AddNew
        	rs.Fields("utente_nome").value = fname
            rs.Fields("utente_cognome").value = lname
            rs.Fields("utente_user").value = nickname
            rs.Fields("utente_emailShow").value = chk
            rs.Fields("imagePath").value = NewFil
            rs.Fields("utente_password").value = key
     		rs.Fields("maleFemale").value = sex 
     		rs.Fields("U_Time").value = Now()
     		rs.Fields("utente_email").value = email
    		rs.Fields("hobbies").value = hobbies 
    		rs.Fields("utente_informazione").value = aboutme
    		rs.Fields("Cust_Country").value = country 
    		rs.Update
            rs.close
    dim snd 
    snd = false        
       'Send email to new user with his/her id and password for editing informations.
    msubject = "Welcome to profile web site"
    mbody = "<table border=0  width='100%' bgcolor=lightyellow>"
    mbody = "<tr><Td><fieldset><legend><font color='blue' face='verdana' size='3pt'>"
    mbody = "Admin: Shah Hussain (Shah thefire)</legend></font>
    
    <table border=0 cellspacing=6 cellpaddig=7 width='100%' bgcolor='black'>"
    mbody = mbody & "<TR><TD>[b]<font color=white face=verdana>Hello Dear User "& nickname &"<font></td></tr>"
    mbody = mbody & "<tr><td><font color=lightblue face=verdana size=3pt>Please keep your Details:</font></td></tr>"
    mbody = mbody & "<tr><td><font color=lightgreen face=verdana size=3pt><blockquote>"
    mbody = mbody & "[list=1][*]Your Nick Name is  : " & nickname &""
    mbody = mbody & "[*]Your First Name is  : " & fname &""
    mbody = mbody & "[*]Your Last Name is  : " & lname &""
    mbody = mbody & "[*]Your Password is  : " & key &""
    mbody = mbody & "</td></tr><tr><td bgcolor=lightyellow><font color=blue face=verdan>"
    mbody = mbody & "<div align=center>If you want to Edit your Profile click on the link:"
    mbody = mbody & "Edit Profile </font></div></td></tr></table>
    </fieldset>"
    smailserver = "127.0.0.1"
    Set objmail = Server.CreateObject("CDO.Message")
    Set objconf = Server.CreateObject("CDO.configuration")
    Set objfields = objconf.Fields
    with objFields
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smailserver
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    .Update
    End with
    with objmail
    set.Configuration = objconf
    .From = "Admin Shah Thefire" 
    .To = Trim(Upload.Form("email"))
    .Subject = msubject
    .HTMLBody = mbody
    End with
    Err.Clear
    on Error Resume Next
    objmail.Send
    If Len(Err.Description) = 0 Then
    snd = true
    Else
    snd = false
    End IF
    'response.write"
    
    
    
    <div align=center><font color='blue' face=verdana size=3pt>"
    'response.write"Your Profile Details has been sent to your eamil :" & email & " </font></div>
    "
    set objFields = Nothing
    set objConf = Nothing
    set objMail = Nothing
    'Response.write("<div style='background-color:blue;'>" & snd &"</div>")
    
            Response.Redirect("default.asp?ok=Welcome")
        Else
        	set fs = Server.CreateObject("Scripting.FileSystemObject")
    	  IF(fs.FileExists(Server.MapPath("pictures/temp/" & Session("pic")))) Then
    		set ts = fs.GetFile(Server.MapPath("pictures/temp/" & Session("pic")))
    		ts.Delete
    	   End If
    		set fs = Nothing
        	Response.Redirect("makeProfile.asp?ok=alreadyExists")
        End If
     		set rs = nothing 
     		con.close
     		set con = Nothing
       %>
            
    </BODY>
    </HTML>
    JK

  10. #10
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Ovvero? Quale sarebbe il problema? Lo dobbiamo immaginare?

    Roby

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.