Jump to content

[SOLVED] choosing from list menu to decide where to put file


justAnoob

Recommended Posts

I have a list menu of a couple categories. I have a folder on my server called userimages with the category sub folders off of that. Right now we got a upload script to upload all pictures to the main userimages folder. How would I go about intergrating a list menu so the user can pick the category he or she would like the file to go into. Here is what I got so far.

<?php

		$image_name=time().'.'.$extension;
		$newname="userimages/".$image_name;
		$copied = copy($_FILES['image']['tmp_name'], $newname);
?>

Any tutorials out there or step by steps or any ideas. Thanks again.

assuming your upload script is working currently, you should have a path where the images are currently getting uploaded. 

have another item in your form, a SELECT menu with the possible subcategories, then take the entry they selected and insert it into the path where the file will be going

 

in theory

upload script works properly, all files just go to main userimages folder. I have sub folders created already. How would I go about the whole variable thing... something like this??>>>>>

<?php
                                       $listmenu = 
		$image_name=time().'.'.$extension;
		$newname="userimages/$listmenu/".$image_name;
		$copied = copy($_FILES['image']['tmp_name'], $newname);
?>

the list menu options are named identical to the sub folder names just so you know

Here is what I got,,, I'm only showing the code that is relevant to what I am trying to accomplish

The "*****"  are the lines that I started to change for this to work, not sure if that is correct though.

<?php
if(isset($_POST['Submit']))
{
$image=$_FILES['image']['name'];
if ($image)
{
	$filename = stripslashes($_FILES['image']['name']);
	$extension = getExtension($filename);
	$extension = strtolower($extension);
	if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "gif") && ($extension != "png"))
	{
		echo '<h1>Unknown extension!</h1>';
		$errors=1;
	}
	else
	{
		$size=filesize($_FILES['image']['tmp_name']);
		if ($size > MAX_SIZE*1024)
		{
			echo '<h1>You have exceeded the size limit!</h1>';	$errors=1;
		}

		$listmenu =                                                       //******
		$image_name=time().'.'.$extension;
		$newname="userimages/$listmenu/".$image_name;   //*********
		$copied = copy($_FILES['image']['tmp_name'], $newname);

		if (!$copied)
		{
			echo '<h1>Copy unsuccessfull!</h1>';
			$errors=1;
		}
	}
}
}
?>

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.