Im using xHttpServer 0.77 from @Star-Dust,
im trying to upload a file with
unfortunally im getting an error, no matter wich file im trying to upload:
im trying to upload a file with
JavaScript:
document.getElementById('upload-input').addEventListener('change', async (e) => {
const files = e.target.files;
if (!files.length) return;
const formData = new FormData();
for (let file of files) {
if (!file.name.endsWith('.apk')) {
alert('Only APK files are allowed');
return;
}
formData.append('files', file);
}
const progressBar = document.getElementById('upload-progress');
try {
const response = await fetch('/firmware', {
method: 'POST',
body: formData,
onUploadProgress: (progressEvent) => {
const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
progressBar.style.width = percentCompleted + '%';
}
});
if (!response.ok) throw new Error('Upload failed');
alert('Update successful');
} catch (error) {
console.error('Error uploading files:', error);
alert('Update failed');
} finally {
progressBar.style.width = '0';
e.target.value = ''; // Reset file input
}
});
unfortunally im getting an error, no matter wich file im trying to upload:
B4X:
java.lang.ArrayIndexOutOfBoundsException: src.length=1612785 srcPos=-1 dst.length=1612786 dstPos=0 length=1612786
at java.lang.System.arraycopy(Native Method)
at anywheresoftware.b4a.keywords.Bit.ArrayCopy(Bit.java:192)
at b4a.example.servletrequest._subarray(servletrequest.java:1604)
at b4a.example.servletrequest._extractparameterfromdata(servletrequest.java:1151)
at b4a.example.servletrequest._extracthandshake(servletrequest.java:1079)
at b4a.example.servletrequest._astream_newdata(servletrequest.java:223)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
at anywheresoftware.b4a.BA$2.run(BA.java:395)
at android.os.Handler.handleCallback(Handler.java:755)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6141)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
java.lang.ArrayIndexOutOfBoundsException: src.length=1612785 srcPos=-1 dst.length=1612786 dstPos=0 length=1612786