php - Programmatically submit file to website using Java -


i have simple website html file upload form, uses php file user submits. create java app able upload file specific page using form on page.

in more detailed explanation, wan't create java app have specific file in it's directory. whenever app run, submit 1 file "file" input on website , app call submit button on site. there sort of 2 parts, first there actual website, form , php backend done , works supposed. there external app, can have on desktop. run 1 time , have specific file uploaded, without me having enter website , manually. far haven't been able find much, other apache commons library, said have uploading part.

to make time line go, java app connects url, java app inputs/uploads desired file , java app submits actual form.

note: file supposed uploaded regular .txt file

here current script html , php part.

html:

<form enctype="multipart/form-data" action="upload2.php" method="post">     <input type="hidden" name="max_file_size" value="30000" />     send file: <input name="userfile" type="file" />     <input type="submit" value="send file" /> </form> 

php:

<?php $uploaddir = 'uploads/'.uniqid(); $uploadfile = $uploaddir . basename($_files['userfile']['name']);  echo '<pre>'; if (move_uploaded_file($_files['userfile']['tmp_name'], $uploadfile)) {     echo "file valid, , uploaded.\n"; } else {     echo "possible file upload attack!\n"; }  echo 'here more debugging info:'; print_r($_files);  print "</pre>"; ?> 


Comments

Popular posts from this blog

qt - QML MouseArea onWheel event not working properly when inside QML Scrollview -

java - is not an enclosing class / new Intent Cannot Resolve Constructor -

python - Error importing VideoFileClip from moviepy : AttributeError: 'PermissionError' object has no attribute 'message' -