Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » HttpRequest File Upload
Re: HttpRequest File Upload [message #43117 is a reply to message #40184] Thu, 08 May 2014 14:35 Go to previous messageGo to previous message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I am resuming this old post.
I am having problem with the upload file.
This a working PHP file (tested by browser via a html file driver) located in /var/www/vega/logup
<?php
//transfer.php
function Upload($folder)
{       $target = "./". basename( $_FILES['file']['name']) ; 
        echo $target;
        if(copy($_FILES['file']['tmp_name'], $target)) return 1;
        else return 0;
}
Upload("");
?>

It saves the file in the same folder. This is the U++ driver program:
void PublishSiteDlg::PublishVega()
{ 	String fn = TD.PATHDIRWWW+"compress.zip";
	if (FileExists(fn)) DeleteFile(fn);
	FileZip zip(fn);
        String targetdir = TD.PATHDIRWWW;
	FindFile fff(AppendFileName(targetdir, "*.*"));
	while(fff) {
			if(fff.IsFile()) {
		          zip.WriteFile(LoadFile(TD.PATHDIRWWW+fff.GetName()), fff.GetName());
			}
			fff.Next();
	}
	zip.Finish();	//all OK here and the file is created

	HttpRequest req("http://localhost/vega/logup/transfer.php");
	req.POST();
	req.Part("file", LoadFile(fn), "application/zip", fn);
	req.Post("submit", "submit");
	String s = req.Execute();
	Exclamation(s);
}

The previous code shows the echoed file name but no file is uploaded.
What I am missing?
Thanks,
Luigi
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to use Skylark on external server
Next Topic: [SOLVED] Fix some memory leak in IpAddrInfo
Goto Forum:
  


Current Time: Thu May 16 06:16:50 CEST 2024

Total time taken to generate the page: 0.02905 seconds