Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

danilowhxcx

Upload com AspFreeUpload

Recommended Posts

iae pessoal, estou usando o asp free upload que esta fazendo tudo direitinho, porem nao consigo usar a função de deletar do fso.

 

segue o código:

 

function TestEnvironment()
	Dim fso, fileName, testFile, streamTest
	TestEnvironment = ""
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	if not fso.FolderExists(uploadsDirVar) then
		TestEnvironment = "<B>Folder " & uploadsDirVar & " does not exist.</B><br>The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."
		exit function
	end if
	fileName = uploadsDirVar & "\test.txt"
	on error resume next
	Set testFile = fso.CreateTextFile(fileName, true)
	If Err.Number<>0 then
		TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have write permissions.</B><br>The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions."
		exit function
	end if
   Err.Clear
   testFile.Close
   	fso.DeleteFile(fileName)
  If Err.Number<>0 then
		TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have delete permissions</B>, although it does have write permissions.<br>Change the permissions for IUSR_<I>computername</I> on this folder."
		exit function
	end if
	Err.Clear
	Set streamTest = Server.CreateObject("ADODB.Stream")
	If Err.Number<>0 then
		TestEnvironment = "<B>The ADODB object <I>Stream</I> is not available in your server.</B><br>Check the Requirements page for information about upgrading your ADODB libraries."
		exit function
	end if
	Set streamTest = Nothing
end function

function SaveFiles
	Dim Upload, fileName, fileSize, ks, i, fileKey, attach1, attach2

	Set Upload = New FreeASPUpload
	Upload.Save(uploadsDirVar)

	' If something fails inside the script, but the exception is handled
	If Err.Number<>0 then Exit function

	SaveFiles = ""
	ks = Upload.UploadedFiles.keys
	if (UBound(ks) <> -1) then

'################################ SO CONSIGO PUXAR AS VARIAVEIS APARTIR DAQUI... ###################

txt_data = Replace(Upload.Form("txt_data"),"'","´")
txt_titulo = Replace(Upload.Form("txt_titulo"),"'","´")
excluir_foto = Upload.Form("excluir_foto")

flickr1 = Replace(Upload.Form("flickr1"),"'","")
flickr2 = Replace(Upload.Form("flickr2"),"'","")

attach1 = Upload.UploadedFiles("attach1").FileName
attach2 = Upload.UploadedFiles("attach2").FileName



if txt_titulo <> "" or txt_data <> "" then
abre()
	sql14 = "Update fotos set"
	sql14 = sql14 & " legenda ='" & txt_titulo & "',"
	sql14 = sql14 & " data ='" & txt_data & "' "
	sql14 = sql14 & " WHERE id="& id &";"
	set rst3 = Conexao.execute(sql14)
	set rst3 = nothing
fecha()
end if

if attach1 <> "" then
abre()
	sql2 = "Update fotos set"
	sql2 = sql2 & " foto ='" & attach1 & "'"
	sql2 = sql2 & " WHERE id="& id &";"
	set rst2 = Conexao.execute(sql2)
	set rst2 = nothing
fecha()
end if

if attach2 <> "" then
abre()
	sql3 = "Update fotos set"
	sql3 = sql3 & " foto_quadrada ='" & attach2 & "'"
	sql3 = sql3 & " WHERE id="& id &";"
	set rst3 = Conexao.execute(sql3)
	set rst3 = nothing
fecha()
end if


if flickr1 <> "" then
abre()
	sql2 = "Update fotos set"
	sql2 = sql2 & " foto ='" & flickr1 & "'"
	sql2 = sql2 & " WHERE id="& id &";"
	set rst2 = Conexao.execute(sql2)
	set rst2 = nothing
fecha()
end if

if flickr2 <> "" then
abre()
	sql3 = "Update fotos set"
	sql3 = sql3 & " foto_quadrada ='" & flickr2 & "'"
	sql3 = sql3 & " WHERE id="& id &";"
	set rst3 = Conexao.execute(sql3)
	set rst3 = nothing
fecha()
end if

		SaveFiles = "<B>Files uploaded:</B> "
		for each fileKey in Upload.UploadedFiles.keys
			SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) "
		next
	else
		SaveFiles = "O nome do arquivo especificadono formulario de upload não corresponde a um arquivo válido no sistema.."
	end if

end function

se alguem ja usou este componente e ja conseguiu fazer deletar e depois salvar da um grito ai!!! =P

 

vlw abraços

Compartilhar este post


Link para o post
Compartilhar em outros sites

nenhum, por que nao tem nada de errado o problema seria a lógica, pq eu se você perceber no meio do script eu soh consigo puxar as variaveis num certo momento, soh que até ai ele ja teria salvado o arquivo eu teria que colocar antes disso soh nao sei como...

Compartilhar este post


Link para o post
Compartilhar em outros sites

vararq=request.querystring("arq")

Set fso = Server.CreateObject("Scripting.FileSystemObject")

fso.DeleteFile "C:\Inetpub\wwwroot\agenda\" & vararq,false

response.Redirect("delete_arq.asp?msg=1")

...

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.