Hi there..
I'm trying to no avail to use PostMultipart to upload video files to the server. This works well for my images, but now for my mp4 files at all, these are not fully uploaded. I'm calling this from a class...
And I call this using..
The PHP file is...
My JobDone returns a "success" on upload of the file but then the filesize on the server is not the same as the original file and when ftp(ed) back the mp4 file does not play. The php configuration accepts 20MB file sizes and my file is 12MB.
Is there another way I can do this please. Thanks
I'm trying to no avail to use PostMultipart to upload video files to the server. This works well for my images, but now for my mp4 files at all, these are not fully uploaded. I'm calling this from a class...
B4X:
Sub UploadFilePhp(frm As Object, pQuery As Map, dir As String, fil As String, JobName As String, phpFile As String, phpTag As String)
CallSub(frm,"ShowSpinner")
Dim job As HttpJob
Dim fd As MultipartFileData
' initialize the job
job.Initialize(JobName, frm)
job.Tag = phpTag
' initialize the mulipart
fd.Initialize
fd.KeyName = "processfile"
fd.Dir = dir
fd.FileName = fil
' determine the contenttype
If fil.EndsWith(".png") = True Then
fd.ContentType = "image/png"
else If fil.EndsWith(".gif") = True Then
fd.ContentType = "image/gif"
else If fil.EndsWith(".jpg") = True Then
fd.ContentType = "image/jpeg"
else If fil.EndsWith(".jpeg") = True Then
fd.ContentType = "image/jpeg"
else If fil.EndsWith(".json") = True Then
fd.ContentType = "application/json"
else if fil.EndsWith(".pdf") = True Then
fd.ContentType = "application/pdf"
else if fil.EndsWith(".mp4") = True Then
fd.ContentType = "video/mp4"
Else
fd.ContentType = "application/octet-stream"
End If
' execute the script to upload the file
job.PostMultipart(Starter.phpPath & phpFile, pQuery, Array(fd))
Wait For(job) JobDone(job As HttpJob)
End Sub
And I call this using..
B4X:
dbAction.Initialize
dbAction.Put("action", "upload")
dbAction.Put("filepath", "")
Starter.httpjobs.UploadFilePhp(Me,dbAction,File.Combine(File.DirRootExternal,"Videos"), filename, _
"upload", "uploadfile.php", "upload")
The PHP file is...
B4X:
<?php
if (isset($_REQUEST['action'])){$action=trim($_REQUEST['action']);} else {$action="";}
if (isset($_REQUEST['filepath'])){$filepath=trim($_REQUEST['filepath']);} else {$filepath="";}
switch ($action)
{
case "upload":
$filepath = $filepath . basename( $_FILES['processfile']['name']);
if(move_uploaded_file($_FILES['processfile']['tmp_name'], $filepath)) {
echo "success";
} else{
echo "fail";
}
}
?>
My JobDone returns a "success" on upload of the file but then the filesize on the server is not the same as the original file and when ftp(ed) back the mp4 file does not play. The php configuration accepts 20MB file sizes and my file is 12MB.
Is there another way I can do this please. Thanks
Last edited: