-
Notifications
You must be signed in to change notification settings - Fork 1
Home
seif hadjhassen edited this page Jul 24, 2019
·
3 revisions
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.seifhjh:AndroidUploadManager:1.2.0'
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
UploadManager.urlServer="http://host/uploadFile";
}
UploadManager.uploadFileFromFile(getApplicationContext(), file, new UploadManager.OnProgressListener() {
@Override
public void onProgress(long percent) {
Log.e(TAG,"onProgress : "+percent);
}
@Override
public void onComplite(String response) {
Log.e(TAG,"onComplite : "+response);
}
@Override
public void onFailed(Throwable error) {
Log.e(TAG,"onFailed : "+error.getMessage());
}
});
List<File> listFiles=new ArrayList<>();
listFiles.add(file);
listFiles.add(file);
UploadManager.uploadFileFromFile(getApplicationContext(), listFiles, new UploadManager.OnProgressMultiListener() {
@Override
public void onProgress(long percent) {
Log.e(TAG,"onProgress : "+percent);
}
@Override
public void onComplite(List<String> listResponse) {
Log.e(TAG,"onComplite : "+listResponse);
}
@Override
public void onFailed(Throwable error) {
Log.e(TAG,"onFailed : "+error.getMessage());
}
});
<?php
include "conn.php";
try{
$name = time();
$path = $_FILES['file']['name'];
$ext = pathinfo($path, PATHINFO_EXTENSION);
$stored_name ="file-$name.$ext";
if (!file_exists('path/file')) {
mkdir('path/file/', 0777, true);
}
if(move_uploaded_file($_FILES['file']['tmp_name'],"path/file/$stored_name"))
{
mime_content_type('path/file/'.$stored_name);
$result=array(
'master'=>array(
'etat' => "succes",
'url'=> "$host/path/file/$stored_name"
));
}else{
$result=array(
'master'=>array(
'etat' => "failure",
'url'=> "$host/path/file/profil-default.jpg"
));
}
echo json_encode($result);
}catch(Exception $e){
}
?>
{
"master":
{"etat":"succes","url":"http:\/\/host\/path\/file\/file-1563922243.mp4"}
}
Seif Hadjhassen - Github
Seif Hadjhassen - Linked In
Seif Hadjhassen - Facebook
Seif Hadjhassen - Twitter
Seif Hadjhassen - Dribbble
Seif Hadjhassen - Pinterest
Copyright 2019 Seif Hadjhassen
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.