B4A Library Upload file with php

Version 1.0

Requirements:
1- B4A 3.x
2- Copy the UploadFilePhp.xml and UploadFilePhp.jar to your additional libraries directory.

eng

Sorry for my English I translate with google!
This library is used to upload files to the web server through php page.
B4A sends the file to the php page that saves them in the server folder!
ita
Scusate il mio inglese traduco con google!
questa libreria serve a uplodare file nel web server attraverso pagina php.
B4A invia i file alla pagina php che li salva nella cartella del server!


eng
simple php page to be included in your server!
ita
semplice pagina php da inserire nel vostro server!

problem 3g
I only have problems with slow connections with Android 2.3.0



B4X:
Eng
Be careful when you do the tests do not send the same file, change it generates an error if no "why the file on the server can not be written when you are opening!"
Ita
Attenzione quando fate le prove non inviate lo stesso file,cambiatelo se no genera un errore "motivo il file sul server non può essere scritto quando è apperto!"

Attention this code and sample files !!!!
security change you as you please do not take any responsibility!

ITA
Attenzione questo codice e file di esempio!!!!
per la sicurezza modificarlo voi a vostro piacimento non mi prendo alcuna responsabilità!



B4X:
<?php
    $file_path = "uploads/";

    $file_path = $file_path . basename( $_FILES['uploaded_file']['name']);
    if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $file_path)) {
        echo "success";
    } else{
        echo "fail";
    }
?>
B4X:
Dim Up As UploadFilePhp

Up.Initialize("Up")
Up.doFileUpload( ProgressBar1,Label1,Path_Phone_Image & name_image,Url_Php_Page)
 

Attachments

  • UploadfilePhp.zip
    9.7 KB · Views: 1,042
Last edited:

Spinter

Active Member
Licensed User
you can not save the same file with the same name, you must change the name, because if it is still writing you from mistake! can try to change the name of the second file '. tonight to see change your php page.
do you understand what you try to do? excuse my English I translate with google
 

Spinter

Active Member
Licensed User
try to use this to automatically rename the file, but you can only use image file

php use it to test this then edit it creates folders based on the file name and save the file into the folder with a number of growing up!

B4X:
<?php
$extensions = array('.jpg', '.jpeg','.JPG', '.JPEG');
$valid_extensions = '.jpg, .jpeg';
$extension = strrchr($_FILES['uploaded_file']['name'], '.');
if (!in_array($extension, $extensions))
{
die("Estensione Errore!");
}
//cartella principale di salvataggio
$target_path = "uploads/";
$dir=$target_path;
//ricavo la richiesta client e leggo
$target_path2 = $target_path . basename( $_FILES['uploaded_file']['name']);
$target = $target . basename( $_FILES['uploaded_file']['name']);
//tolgo l'estensione
$target_path2 = str_replace(".JPG", "/", $target_path2);
$target_path2 = str_replace(".jpg", "/", $target_path2);
$target_path2 = str_replace(".JPEG", "/", $target_path2);
$target_path2 = str_replace(".jpeg", "/", $target_path2);
//creo cartella con il nome del file
mkdir("$target_path2",0755);
$target_file_mod = imageExists($target,$target_path2);
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path2 .$target_file_mod)) {
echo " The file ". $target_file_mod ." has been uploaded";
} else{
      echo "There was an error uploading the file, please try again!";
}
  function imageExists($image,$dir1) {

    $i=1; $probeer=$image;

    while(file_exists($dir1.$probeer)) {
        $punt=strrpos($image,".");
        if(substr($image,($punt-3),1)!==("[") && substr($image,($punt-1),1)!==("]")) {
            $probeer=substr($image,0,$punt)."[".$i."]".
            substr($image,($punt),strlen($image)-$punt);
        } else {
            $probeer=substr($image,0,($punt-3))."[".$i."]".
            substr($image,($punt),strlen($image)-$punt);
        }
        $i++;
    }
    return $probeer;
}
?>
 
Last edited:

Douglas Farias

Expert
Licensed User
1°UPLOAD ON GALAXY

B4X:
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
(Intent) Intent { act=android.intent.action.MAIN flg=0x20000000 cmp=b4a.Spinter.uploadkk/.main }
no extras
** Activity (main) Create, isFirst = true **
B4A log: Initialize UploadFile library
** Activity (main) Resume **
** Activity (main) Resume **
true \ 0
true \ 0
true \ 0
true \ 0
true \ 0
true \ 0
true \ 0
true \ 0
true \ 0
true \ 0
true \ 0
true \ 1
true \ 1
true \ 1
true \ 1
true \ 1
true \ 1
true \ 1
true \ 1
true \ 1
true \ 1
true \ 1
true \ 1
true \ 2
true \ 2
true \ 2
true \ 2
true \ 2
true \ 2
true \ 2
true \ 2
true \ 2
true \ 2
true \ 2
true \ 3
true \ 3
true \ 3
true \ 3
true \ 3
true \ 3
true \ 3
true \ 3
true \ 3
true \ 3
true \ 3
true \ 3
true \ 4
true \ 4
true \ 4
true \ 4
true \ 4
true \ 4
true \ 4
true \ 4
true \ 4
true \ 4
true \ 4
true \ 5
true \ 5
true \ 5
true \ 5
true \ 5
true \ 5
true \ 5
true \ 5
true \ 5
true \ 5
true \ 5
true \ 5
true \ 6
true \ 6
true \ 6
true \ 6
true \ 6
true \ 6
true \ 6
true \ 6
true \ 6
true \ 6
true \ 6
true \ 7
true \ 7
true \ 7
true \ 7
true \ 7
true \ 7
true \ 7
true \ 7
true \ 7
true \ 7
true \ 7
true \ 7
true \ 8
true \ 8
true \ 8
true \ 8
true \ 8
true \ 8
true \ 8
true \ 8
true \ 8
true \ 8
true \ 8
true \ 9
true \ 9
true \ 9
true \ 9
true \ 9
true \ 9
true \ 9
true \ 9
true \ 9
true \ 9
true \ 9
true \ 9
true \ 10
true \ 10
true \ 10
true \ 10
true \ 10
true \ 10
true \ 10
true \ 10
true \ 10
true \ 10
true \ 10
true \ 11
true \ 11
true \ 11
true \ 11
true \ 11
true \ 11
true \ 11
true \ 11
true \ 11
true \ 11
true \ 11
true \ 11
true \ 12
true \ 12
true \ 12
true \ 12
true \ 12
true \ 12
true \ 12
true \ 12
true \ 12
true \ 12
true \ 12
true \ 13
true \ 13
true \ 13
true \ 13
true \ 13
true \ 13
true \ 13
true \ 13
true \ 13
true \ 13
true \ 13
true \ 13
true \ 14
true \ 14
true \ 14
true \ 14
true \ 14
true \ 14
true \ 14
true \ 14
true \ 14
true \ 14
true \ 14
true \ 15
true \ 15
true \ 15
true \ 15
true \ 15
true \ 15
true \ 15
true \ 15
true \ 15
true \ 15
true \ 15
true \ 15
true \ 16
true \ 16
true \ 16
true \ 16
true \ 16
true \ 16
true \ 16
true \ 16
true \ 16
true \ 16
true \ 16
true \ 17
true \ 17
true \ 17
true \ 17
true \ 17
true \ 17
true \ 17
true \ 17
true \ 17
true \ 17
true \ 17
true \ 17
true \ 18
true \ 18
true \ 18
true \ 18
true \ 18
true \ 18
true \ 18
true \ 18
true \ 18
true \ 18
true \ 18
true \ 19
true \ 19
true \ 19
true \ 19
true \ 19
true \ 19
true \ 19
true \ 19
true \ 19
true \ 19
true \ 19
true \ 19
true \ 20
true \ 20
true \ 20
true \ 20
true \ 20
true \ 20
true \ 20
true \ 20
true \ 20
true \ 20
true \ 20
true \ 21
true \ 21
true \ 21
true \ 21
true \ 21
true \ 21
true \ 21
true \ 21
true \ 21
true \ 21
true \ 21
true \ 21
true \ 22
true \ 22
true \ 22
true \ 22
true \ 22
true \ 22
true \ 22
true \ 22
true \ 22
true \ 22
true \ 22
true \ 23
true \ 23
true \ 23
true \ 23
true \ 23
true \ 23
true \ 23
true \ 23
true \ 23
true \ 23
true \ 23
true \ 23
true \ 24
true \ 24
true \ 24
true \ 24
true \ 24
true \ 24
true \ 24
true \ 24
true \ 24
true \ 24
true \ 24
true \ 25
true \ 25
true \ 25
true \ 25
true \ 25
true \ 25
true \ 25
true \ 25
true \ 25
true \ 25
true \ 25
true \ 25
true \ 26
true \ 26
true \ 26
true \ 26
true \ 26
true \ 26
true \ 26
true \ 26
true \ 26
true \ 26
true \ 26
true \ 27
true \ 27
true \ 27
true \ 27
true \ 27
true \ 27
true \ 27
true \ 27
true \ 27
true \ 27
true \ 27
true \ 27
true \ 28
true \ 28
true \ 28
true \ 28
true \ 28
true \ 28
true \ 28
true \ 28
true \ 28
true \ 28
true \ 28
true \ 29
true \ 29
true \ 29
true \ 29
true \ 29
true \ 29
true \ 29
true \ 29
true \ 29
true \ 29
true \ 29
true \ 29
true \ 30
true \ 30
true \ 30
true \ 30
true \ 30
true \ 30
true \ 30
true \ 30
true \ 30
true \ 30
true \ 30
true \ 31
true \ 31
true \ 31
true \ 31
true \ 31
true \ 31
true \ 31
true \ 31
true \ 31
true \ 31
true \ 31
true \ 31
true \ 32
true \ 32
true \ 32
true \ 32
true \ 32
true \ 32
true \ 32
true \ 32
true \ 32
true \ 32
true \ 32
true \ 33
true \ 33
true \ 33
true \ 33
true \ 33
true \ 33
true \ 33
true \ 33
true \ 33
true \ 33
true \ 33
true \ 33
true \ 34
true \ 34
true \ 34
true \ 34
true \ 34
true \ 34
true \ 34
true \ 34
true \ 35
true \ 35
true \ 35
true \ 35
true \ 35
true \ 35
true \ 35
true \ 35
true \ 35
true \ 36
true \ 36
true \ 36
true \ 36
true \ 36
true \ 36
true \ 36
true \ 36
true \ 36
true \ 36
true \ 36
true \ 37
true \ 37
true \ 37
true \ 37
true \ 37
true \ 37
true \ 37
true \ 37
true \ 37
true \ 37
true \ 37
true \ 37
true \ 38
true \ 38
true \ 38
true \ 38
true \ 38
true \ 38
true \ 38
true \ 38
true \ 38
true \ 38
true \ 38
true \ 39
true \ 39
true \ 39
true \ 39
true \ 39
true \ 39
true \ 39
true \ 39
true \ 39
true \ 39
true \ 39
true \ 39
true \ 40
true \ 40
true \ 40
true \ 40
true \ 40
true \ 40
true \ 40
true \ 40
true \ 40
true \ 40
true \ 40
true \ 41
true \ 41
true \ 41
true \ 41
true \ 41
true \ 41
true \ 41
true \ 41
true \ 41
true \ 41
true \ 41
true \ 41
true \ 42
true \ 42
true \ 42
true \ 42
true \ 42
true \ 42
true \ 42
true \ 42
true \ 42
true \ 42
true \ 42
true \ 43
true \ 43
true \ 43
true \ 43
true \ 43
true \ 43
true \ 43
true \ 43
true \ 43
true \ 43
true \ 43
true \ 43
true \ 44
true \ 44
true \ 44
true \ 44
true \ 44
true \ 44
true \ 45
true \ 45
true \ 45
true \ 45
true \ 45
true \ 45
true \ 45
true \ 45
true \ 45
true \ 45
true \ 46
true \ 46
true \ 46
true \ 46
true \ 46
true \ 46
true \ 46
true \ 46
true \ 46
true \ 46
true \ 46
true \ 47
true \ 47
true \ 47
true \ 47
true \ 47
true \ 47
true \ 47
true \ 47
true \ 47
true \ 47
true \ 47
true \ 47
true \ 48
true \ 48
true \ 48
true \ 48
true \ 48
true \ 48
true \ 48
true \ 48
true \ 48
true \ 48
true \ 48
true \ 49
true \ 49
true \ 49
true \ 49
true \ 49
true \ 49
true \ 49
true \ 49
true \ 49
true \ 49
true \ 49
true \ 49
true \ 50
true \ 50
true \ 50
true \ 50
true \ 50
true \ 50
true \ 50
true \ 50
true \ 50
true \ 50
true \ 50
true \ 51
true \ 51
true \ 51
true \ 51
true \ 51
true \ 51
true \ 51
true \ 51
true \ 51
true \ 51
true \ 51
true \ 51
true \ 52
true \ 52
true \ 52
true \ 52
true \ 52
true \ 52
true \ 52
true \ 52
true \ 52
true \ 52
true \ 52
true \ 53
true \ 53
true \ 53
true \ 53
true \ 53
true \ 53
true \ 53
true \ 53
true \ 53
true \ 53
true \ 53
true \ 53
true \ 54
true \ 54
true \ 54
true \ 54
true \ 54
true \ 54
true \ 54
true \ 54
true \ 54
true \ 54
true \ 54
true \ 55
true \ 55
true \ 55
true \ 55
true \ 55
true \ 55
true \ 55
true \ 55
true \ 55
true \ 55
true \ 55
true \ 55
true \ 56
true \ 56
true \ 56
true \ 56
true \ 56
true \ 56
true \ 56
true \ 56
true \ 56
true \ 56
true \ 56
true \ 57
true \ 57
true \ 57
true \ 57
true \ 57
true \ 57
true \ 57
true \ 57
true \ 57
true \ 57
true \ 57
true \ 57
true \ 58
true \ 58
true \ 58
true \ 58
true \ 58
true \ 58
true \ 58
true \ 58
true \ 58
true \ 58
true \ 58
true \ 59
true \ 59
true \ 59
true \ 59
true \ 59
true \ 59
true \ 59
true \ 59
true \ 59
true \ 59
true \ 59
true \ 59
true \ 60
true \ 60
true \ 60
true \ 60
true \ 60
true \ 60
true \ 60
true \ 60
true \ 60
true \ 60
true \ 60
true \ 61
true \ 61
true \ 61
true \ 61
true \ 61
true \ 61
true \ 61
true \ 61
true \ 61
true \ 61
true \ 61
true \ 61
true \ 62
true \ 62
true \ 62
true \ 62
true \ 62
true \ 62
true \ 62
true \ 62
true \ 62
true \ 62
true \ 62
true \ 63
true \ 63
true \ 63
true \ 63
true \ 63
true \ 63
true \ 63
true \ 63
true \ 63
true \ 63
true \ 63
true \ 63
true \ 64
true \ 64
true \ 64
true \ 64
true \ 64
true \ 64
true \ 64
true \ 64
true \ 64
true \ 64
true \ 64
true \ 65
true \ 65
true \ 65
true \ 65
true \ 65
true \ 65
true \ 65
true \ 65
true \ 65
true \ 65
true \ 65
true \ 65
true \ 66
true \ 66
true \ 66
true \ 66
true \ 66
true \ 66
true \ 66
true \ 66
true \ 66
true \ 66
true \ 66
true \ 67
true \ 67
true \ 67
true \ 67
true \ 67
true \ 67
true \ 67
true \ 67
true \ 67
true \ 67
true \ 67
true \ 67
true \ 68
true \ 68
true \ 68
true \ 68
true \ 68
true \ 68
true \ 68
true \ 68
true \ 68
true \ 68
true \ 68
true \ 69
true \ 69
true \ 69
true \ 69
true \ 69
true \ 69
true \ 69
true \ 69
true \ 69
true \ 69
true \ 69
true \ 69
true \ 70
true \ 70
true \ 70
true \ 70
true \ 70
true \ 70
true \ 70
true \ 70
true \ 70
true \ 70
true \ 70
true \ 71
true \ 71
true \ 71
true \ 71
true \ 71
true \ 71
true \ 71
true \ 71
true \ 71
true \ 71
true \ 71
true \ 71
true \ 72
true \ 72
true \ 72
true \ 72
true \ 72
true \ 72
true \ 72
true \ 72
true \ 72
true \ 72
true \ 72
true \ 73
true \ 73
true \ 73
true \ 73
true \ 73
true \ 73
true \ 73
true \ 73
true \ 73
true \ 73
true \ 73
true \ 73
true \ 74
true \ 74
true \ 74
true \ 74
true \ 74
true \ 74
true \ 74
true \ 74
true \ 74
true \ 74
true \ 74
true \ 75
true \ 75
true \ 75
true \ 75
true \ 75
true \ 75
true \ 75
true \ 75
true \ 75
true \ 75
true \ 75
true \ 75
true \ 76
true \ 76
true \ 76
true \ 76
true \ 76
true \ 76
true \ 76
true \ 76
true \ 76
true \ 76
true \ 76
true \ 77
true \ 77
true \ 77
true \ 77
true \ 77
true \ 77
true \ 77
true \ 77
true \ 77
true \ 77
true \ 77
true \ 77
true \ 78
true \ 78
true \ 78
true \ 78
true \ 78
true \ 78
true \ 78
true \ 78
true \ 78
true \ 78
true \ 78
true \ 79
true \ 79
true \ 79
true \ 79
true \ 79
true \ 79
true \ 79
true \ 79
true \ 79
true \ 79
true \ 79
true \ 79
true \ 80
true \ 80
true \ 80
true \ 80
true \ 80
true \ 80
true \ 80
true \ 80
true \ 80
true \ 80
true \ 80
true \ 81
true \ 81
true \ 81
true \ 81
true \ 81
true \ 81
true \ 81
true \ 81
true \ 81
true \ 81
true \ 81
true \ 81
true \ 82
true \ 82
true \ 82
true \ 82
true \ 82
true \ 82
true \ 82
true \ 82
true \ 82
true \ 82
true \ 82
true \ 83
true \ 83
true \ 83
true \ 83
true \ 83
true \ 83
true \ 83
true \ 83
true \ 83
true \ 83
true \ 83
true \ 83
true \ 84
true \ 84
true \ 84
true \ 84
true \ 84
true \ 84
true \ 84
true \ 84
true \ 84
true \ 84
true \ 84
true \ 85
true \ 85
true \ 85
true \ 85
true \ 85
true \ 85
true \ 85
true \ 85
true \ 85
true \ 85
true \ 85
true \ 85
true \ 86
true \ 86
true \ 86
true \ 86
true \ 86
true \ 86
true \ 86
true \ 86
true \ 86
true \ 86
true \ 86
true \ 87
true \ 87
true \ 87
true \ 87
true \ 87
true \ 87
true \ 87
true \ 87
true \ 87
true \ 87
true \ 87
true \ 87
true \ 88
true \ 88
true \ 88
true \ 88
true \ 88
true \ 88
true \ 88
true \ 88
true \ 88
true \ 88
true \ 88
true \ 89
true \ 89
true \ 89
true \ 89
true \ 89
true \ 89
true \ 89
true \ 89
true \ 89
true \ 89
true \ 89
true \ 89
true \ 90
true \ 90
true \ 90
true \ 90
true \ 90
true \ 90
true \ 90
true \ 90
true \ 90
true \ 90
true \ 90
true \ 91
true \ 91
true \ 91
true \ 91
true \ 91
true \ 91
true \ 91
true \ 91
true \ 91
true \ 91
true \ 91
true \ 91
true \ 92
true \ 92
true \ 92
true \ 92
true \ 92
true \ 92
true \ 92
true \ 92
true \ 92
true \ 92
true \ 92
true \ 93
true \ 93
true \ 93
true \ 93
true \ 93
true \ 93
true \ 93
true \ 93
true \ 93
true \ 93
true \ 93
true \ 93
true \ 94
true \ 94
true \ 94
true \ 94
true \ 94
true \ 94
true \ 94
true \ 94
true \ 94
true \ 94
true \ 94
true \ 95
true \ 95
true \ 95
true \ 95
true \ 95
true \ 95
true \ 95
true \ 95
true \ 95
true \ 95
true \ 95
true \ 95
true \ 96
true \ 96
true \ 96
true \ 96
true \ 96
true \ 96
true \ 96
true \ 96
true \ 96
true \ 96
true \ 96
true \ 97
true \ 97
true \ 97
true \ 97
true \ 97
true \ 97
true \ 97
true \ 97
true \ 97
true \ 97
true \ 97
true \ 97
true \ 98
true \ 98
true \ 98
true \ 98
true \ 98
true \ 98
true \ 98
true \ 98
true \ 98
true \ 98
true \ 98
true \ 99
true \ 99
true \ 99
true \ 99
true \ 99
true \ 99
true \ 99
true \ 99
true \ 99
true \ 99
true \ 99
true \ 99
true \ 100
<br />
<b>Notice</b>:  Undefined variable: target in <b>C:\xampp\htdocs\clickfight\teste\recebe.php</b> on line <b>14</b><br />
<br />
<b>Warning</b>:  mkdir(): File exists in <b>C:\xampp\htdocs\clickfight\teste\recebe.php</b> on line <b>21</b><br />
The file 1[1].jpg has been uploaded
B4A log: Disconnect!
false \
B4A log: End Upload
false \

WORKS FINE MAKE A DIR AND PUT THE IMAGE INSIDE


NOW 2° UPLOAD
** Activity (main) Resume **
true \ 0
true \ 0
true \ 0
true \ 0
true \ 0
true \ 0
true \ 0
true \ 0
true \ 0
true \ 0
true \ 0
true \ 1
true \ 1
true \ 1
true \ 1
true \ 1
true \ 1
true \ 1
true \ 1
true \ 1
true \ 1
true \ 1
true \ 1
true \ 2
true \ 2
true \ 2
true \ 2
true \ 2
true \ 2
true \ 2
true \ 2
true \ 2
true \ 2
true \ 2
true \ 3
true \ 3
true \ 3
true \ 3
true \ 3
true \ 3
true \ 3
true \ 3
true \ 3
true \ 3
true \ 3
true \ 3
true \ 4
true \ 4
true \ 4
true \ 4
true \ 4
true \ 4
true \ 4
true \ 4
true \ 4
true \ 4
true \ 4
true \ 5
true \ 5
true \ 5
true \ 5
true \ 5
true \ 5
true \ 5
true \ 5
true \ 5
true \ 5
true \ 5
true \ 5
true \ 6
true \ 6
true \ 6
true \ 6
true \ 6
true \ 6
true \ 6
true \ 6
true \ 6
true \ 6
true \ 6
true \ 7
true \ 7
true \ 7
true \ 7
true \ 7
true \ 7
true \ 7
true \ 7
true \ 7
true \ 7
true \ 7
true \ 7
true \ 8
true \ 8
true \ 8
true \ 8
true \ 8
true \ 8
true \ 8
true \ 8
true \ 8
true \ 8
true \ 8
true \ 9
true \ 9
true \ 9
true \ 9
true \ 9
true \ 9
true \ 9
true \ 9
true \ 9
true \ 9
true \ 9
true \ 9
true \ 10
true \ 10
true \ 10
true \ 10
true \ 10
true \ 10
true \ 10
true \ 10
true \ 10
true \ 10
true \ 10
true \ 11
true \ 11
true \ 11
true \ 11
true \ 11
true \ 11
true \ 11
true \ 11
true \ 12
true \ 12
true \ 12
true \ 12
true \ 12
true \ 12
true \ 13
true \ 13
true \ 13
true \ 13
true \ 13
true \ 13
true \ 13
true \ 13
true \ 13
true \ 13
true \ 13
true \ 13
true \ 14
true \ 14
true \ 14
true \ 14
true \ 14
true \ 14
true \ 14
true \ 14
true \ 14
true \ 14
true \ 14
true \ 15
true \ 15
true \ 15
true \ 15
true \ 15
true \ 15
true \ 15
true \ 15
true \ 15
true \ 15
true \ 15
true \ 15
true \ 16
true \ 16
true \ 16
true \ 16
true \ 16
true \ 16
true \ 16
true \ 16
true \ 16
true \ 16
true \ 16
true \ 17
true \ 17
true \ 17
true \ 17
true \ 17
true \ 17
true \ 17
true \ 17
true \ 17
true \ 17
true \ 17
true \ 17
true \ 18
true \ 18
true \ 18
true \ 18
true \ 18
true \ 18
true \ 18
true \ 18
true \ 18
true \ 18
true \ 18
true \ 19
true \ 19
true \ 19
true \ 19
true \ 19
true \ 19
true \ 19
true \ 19
true \ 19
true \ 19
true \ 19
true \ 19
true \ 20
true \ 20
true \ 20
true \ 20
true \ 20
true \ 20
true \ 20
true \ 20
true \ 20
true \ 20
true \ 20
true \ 21
true \ 21
true \ 21
true \ 21
true \ 21
true \ 21
true \ 21
true \ 21
true \ 21
true \ 21
true \ 21
true \ 21
true \ 22
true \ 22
true \ 22
true \ 22
true \ 22
true \ 22
true \ 22
true \ 22
true \ 22
true \ 22
true \ 22
true \ 23
true \ 23
true \ 23
true \ 23
true \ 23
true \ 23
true \ 23
true \ 23
true \ 23
true \ 23
true \ 23
true \ 23
true \ 24
true \ 24
true \ 24
true \ 24
true \ 24
true \ 24
true \ 24
true \ 24
true \ 24
true \ 24
true \ 24
true \ 25
true \ 25
true \ 25
true \ 25
true \ 25
true \ 25
true \ 25
true \ 25
true \ 25
true \ 25
true \ 25
true \ 25
true \ 26
true \ 26
true \ 26
true \ 26
true \ 26
true \ 26
true \ 26
true \ 26
true \ 26
true \ 26
true \ 26
true \ 27
true \ 27
true \ 27
true \ 27
true \ 27
true \ 27
true \ 27
true \ 27
true \ 27
true \ 27
true \ 27
true \ 27
true \ 28
true \ 28
true \ 28
true \ 28
true \ 28
true \ 28
true \ 28
true \ 28

GO VERY FAST TO 28% AND STOP ON THIS

PROGRESSBAR STOP ON 28%

ONLY ON GALAXY S3 AND galaxy star moto g no problem *-*

it is not problem with php =(
 

Douglas Farias

Expert
Licensed User
hmmmmmmmmmmmmmmmmmmmmmmmmmmmm i find the problem *-*-*-*-*-*
realy dont is on php the problem

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example Upload
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim Up As UploadFilePhp
End Sub


Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private Button1 As Button
    Private Button2 As Button
    Private Label1 As Label
    Private Label2 As Label
    Private ProgressBar1 As ProgressBar
    Dim Url_Php_Page As String
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout_upload")
    Url_Php_Page="http://74.63.193.55/clickfight/teste/recebe.php"
   
    If FirstTime Then
        Up.B4A_log=True
        Up.Initialize("Up")
    End If
   
    File.Copy(File.DirAssets, "1.jpg", File.DirRootExternal , "1.jpg")
    File.Copy(File.DirAssets, "2.jpg", File.DirRootExternal , "2.jpg")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean
  If KeyCode=KeyCodes.KEYCODE_BACK Then
  Dim domanda2 As Int
  domanda2 =  Msgbox2("Vuoi Uscire?","Avviso","Yes","","No",Null)
  If domanda2 = DialogResponse.POSITIVE Then
  Up.UploadKill
  ExitApplication
  Else If domanda2 = DialogResponse.NEGATIVE Then
  Return True
  End If
  End If
  Return True
End Sub

Sub Up_statusUpload (value As String)
    'Label1.Text=value
    'Label2.Text=value
End Sub
Sub Up_sendFile (value As String)
    Label2.Text=value
End Sub
Sub Up_statusVISIBLE (onoff As Boolean,value As String)
      Log(onoff&" \ "&value)
End Sub

Sub Button1_Click
Dim files As List
files.Initialize




Label1.Text="Enviando Imagem"
Label2.Text="Enviando Imagem"

Dim Path_Phone_Image As String

Path_Phone_Image = File.DirRootExternal & "/"  'OR  "/sdcard/


Dim name_image As String
name_image="1.jpg"




files.Add(Path_Phone_Image & name_image)

Up.doFileUpload( ProgressBar1,Label1,Path_Phone_Image & name_image,Url_Php_Page )   

End Sub
Sub Button2_Click
Dim files As List
files.Initialize




Label1.Text="Enviando Imagem"
Label2.Text="Enviando Imagem"

Dim Path_Phone_Image As String

Path_Phone_Image = File.DirRootExternal & "/"  'OR  "/sdcard/


Dim name_image As String
name_image="2.jpg"




files.Add(Path_Phone_Image & name_image)

Up.doFileUpload( ProgressBar1,Label1,Path_Phone_Image & name_image,Url_Php_Page )   


End Sub

look at this!
the problem is on app
i cant send 1.jpg

later 1.jpg again

u need send 1.jpg later 2.jpg later 1.jpg again
never same value
and it works

look at this code i make 2 buttons
1° button = 1.jpg
2° button = 2.jpg

NO PROBLEM ;)

THX fow u help man ;)

add this change to your original code *-*
 

Douglas Farias

Expert
Licensed User
now working fine i m sending random image names by app from php *-*

last question is possible add on this lib multiple file send?
later i go need send 2 images picture + background

have a chance of add this with
List and filedata?
 

Spinter

Active Member
Licensed User
I'll think, at this moment I'm working on another thing I do not have time to change something that works!
I know you work?
 

Douglas Farias

Expert
Licensed User
i m working on a social app
batle photos

*-* have mysql, facebook and google interation your lib is much important for me at this time *-*
now its working fine

just later i go need send 2 images at same time *-*
 

Phayao

Active Member
Licensed User
Spinter, you saved my day with this great LIB - after struggling with job.postfile for several hours....
Thanks a lot ! :cool:
Chris
 

Mahares

Expert
Licensed User
I tried the sample along with its php file. The only thing I changed is the site URL and the file to upload and its name. It always 'Fails'. I get this log:
<b>Warning</b>: move_uploaded_file() [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: Unable to move 'D:\Temp\php\phpF091.tmp' to 'uploads/Silas021415.jpg' in <b>D:\Hosting\9282749\html\FTPfolders\CSI\Image\upload_file.php</b> on line <b>7</b><br />

Did anyone succeed to run the sample in this library? If so, how and where do you store the web site user and password. I did not see a placeholder for them in the php or B4A code.
Thank you
 

G-ShadoW

Active Member
Licensed User
Why I cant use my php file for upload ?

PHP:
<?php
//add only 1 line from uploaded text file to existing text file
//file_path to the saved file.
$file_path = 'uploads/';
//file name of the temp file:
$file_name =  sys_get_tmp_dir() . $_SERVER['uploaded_file']['tmp_name'];
//name of the saved file.
$new_file = $_SERVER['uploaded_file']['tmp_name'];
//if temp file doesn't exist.
if(!file_exists($file_name)) {
exit('The requested file was not uploaded.');
}
//if the file exists, then get it's contents into a string.
$contents = file_get_contents($file_name);
//test for expected data.
$contents = preg_replace('/[^0-9:.;]/','',$contents);
//append it to the saved file, testing to make sure it saved.
if(file_put_contents($file_path . $new_file,$contents . PHP_EOL, FILE_APPEND) !== FALSE) {
echo 'success.';
}

I want to update text file what is already on server, not to overwrite it !
 

G-ShadoW

Active Member
Licensed User
Ooopss, my mistake, it works now PHP is modifyed

PHP:
<?php
//add only 1 line from uploaded text file to existing text file
//file_path to the saved file.
$file_path = 'uploads/';
//file name of the temp file:
$file_name = $_FILES['uploaded_file']['tmp_name'];
    //name of the saved file.
    $new_file = $_FILES['uploaded_file']['name'];
//if temp file doesn't exist.
if(!file_exists($file_name)) {
exit('The requested file was not uploaded.');
}
//if the file exists, then get it's contents into a string.
$contents = file_get_contents($file_name);
//test for expected data.
$contents = preg_replace('/[^0-9:.;]/','',$contents);
//append it to the saved file, testing to make sure it saved.
if(file_put_contents($file_path . $new_file,$contents . PHP_EOL, FILE_APPEND) !== FALSE) {
echo 'success.';
}
 
Top