PHP File Uploads

54 views
Skip to first unread message

Erik Watson

unread,
Apr 7, 2014, 9:17:15 AM4/7/14
to haxe...@googlegroups.com
Hey there everyone, I'm having a little trouble getting an image to upload to a directory on my testing server with the PHP target and was wondering if you could help?
A file is created in the right location but the resulting image is invalid and its file size is much smaller than it should be.

This is what I've got so far, I'm pretty inexperienced with parseMultipart and outputting files so I might just be doing something ridiculous.

var part:String;
var filename:String;
var byt:Bytes;
var output:FileOutput;

Web.parseMultipart(
   
function(partName:String, fileName:String):Void {
        part
= partName;

        filename
= fileName;
   
},

   
function(dt:Bytes, pos:Int, len:Int):Void {
                       
       
if(part == "image") {
            output
= File.write(filename, true);
            output
.write(dt);
       
}
   
}
);

Any ideas? Thanks!

Marc Weber

unread,
Apr 7, 2014, 11:39:24 AM4/7/14
to haxelang
> Any ideas? Thanks!
https://bitbucket.org/haxecommunity/haxe-cross-request-response/src/1c31956ace2b3ad71367b8949f294a17b3d9d189/src/web/RequestResponseHelper.hx?at=master
Use native PHP file processing. See function file() and you're done
fast.

Keep in mind that PHP has upload size / amount limits (which you can
increase).

Marc Weber
Reply all
Reply to author
Forward
0 new messages