Jump to content

trouble with dir management and file uploading


Sabmin

Recommended Posts

Trying to a. check if dir exists if not create it, and b. save an uploaded file to that directory.  Nothing however is working but I'm pulling no errors, heres the code:

 


$test_pic = $_POST['test_pic'];
// I've also tried       $test_pic = $_FILES["test_pic"];     : with no success
if (is_uploaded_file($test_pic)) {
		if (!file_exists("tests/uploads/" . $test_name . "/")) {
			$create_test_folder = (mkdir("tests/uploads/" . $test_name));
			if (!$create_test_folder) {
				echo "cant create folder";
				die;
			}
		}
		$target_path = ("tests/uploads/" . $test_name . "/" . $test_name . "_1");
		if (($_FILES["test_pic"]["type"] == "image/gif")
	 	 || ($_FILES["test_pic"]["type"] == "image/jpeg")
		 || ($_FILES["test_pic"]["type"] == "image/jpg")
		 || ($_FILES["test_pic"]["type"] == "image/png")
		 && ($_FILES["test_pic"]["size"] < 50000)) {
			if (!copy($test_pic, $target_path)) {
				echo "cant copy picture";
				die;
			}
		} else {
			echo "file type or size bad";
			die;
		}
	}

 

and I understand its not at all public-safe but I'm just wanting to get it to work before I throw in the security.  Thanks for the help!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.