iOS Question postmultipart and chmod

tufanv

Expert
Licensed User
Longtime User
Hello ,

I use the below code to upload files:

B4X:
Dim MFD As MultipartFileData
    MFD.Initialize
    MFD.Dir = File.DirDocuments
    MFD.FileName = sen
    MFD.KeyName = "userfile"
    H.PostMultipart("",Null,Array(MFD))
    H.PostMultipart("server",CreateMap("username":"b4x","password":"supersafe"),Array(MFD))

and php side is:

B4X:
$uploaddir = '/home/www/uploads';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
    echo "File is valid, and was successfully uploaded.\n";
} else {
    echo "Possible file upload attack!\n";
}

if I dont set the upload dir chmod to 777 file is not being uploaded. Even 755 chmod is not enough. Chmod 777 may be a security risk for me so , what should I do with this ? Is there a reason I cant upload without chmod 777 ?

TY
 
Top