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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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;
		}
	}
}
}
?>

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.