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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.