Make sure you run chmod -R 777 uploads/
and change line 5
of upload.py
to the target machine's IP!
Last active
September 10, 2016 18:42
-
-
Save Jbithell/5ace47e34f424c7eea851f4c27355b98 to your computer and use it in GitHub Desktop.
Raspberry Pi - Photo Booth!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//DISPLAY THE LATEST 4 IMAGES IN THE DIRECTORY | |
$DISPLAY = array(); | |
$FILES = scandir("uploads/", SCANDIR_SORT_DESCENDING); | |
for ($x = 0; $x < 4; $x++) { | |
$DISPLAY[] = $FILES[$x]; | |
} | |
foreach ($DISPLAY as $image) { | |
echo '<img src="uploads/' . $image . '" style="width: 100%;" alt="Image" />'; | |
} | |
?> | |
<meta http-equiv="refresh" content="2" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fill this file with this image: http://placekitten.com/1000/1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//FOR THE PYTHON SCRIPT TO UPLOAD TO | |
$target_dir = "uploads/"; | |
$target_file = $target_dir . time() . "." . pathinfo($_FILES["file"]["name"],PATHINFO_EXTENSION); | |
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); | |
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" | |
&& $imageFileType != "gif" ) die("INCORRECT FILE TYPE"); | |
// Check if $uploadOk is set to 0 by an error | |
if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) echo "1"; | |
else echo "ERROR"; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#The Python Upload Script | |
import requests | |
url = 'http://URLHERE/upload.php' | |
files = {'file': open('kitten.jpg', 'rb')} | |
r = requests.post(url, files=files) | |
if (r.text == "1"): | |
print("Success") | |
else: | |
print("FAIL_FAIL_FAIL") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tested & confirmed to be working