isaaccs Posted September 10, 2006 Share Posted September 10, 2006 Hi,I've been looking for hours on how to do this. It seems so simple, but I can't find the answer.I've built an upload page that allows user to select and upload TWO files. I've got a processing script, but it seems I can only deal with ONE of the uploaded files, or I can act on the array, but I can't seem to act on the two instances of the array independently of each other. Ie, I want the first file saved in a certain directory, and it's name stored as a variable for later use, and I want the second file stored in another location, and it's name stored seperatley as a variable for later use.Any suggestions?Thanks much... Quote Link to comment https://forums.phpfreaks.com/topic/20323-accessing-a-specific-instance-of-a-_files-array/ Share on other sites More sharing options...
HuggieBear Posted September 10, 2006 Share Posted September 10, 2006 Perhaps you could post your code, I see nothing impossible about this request.RegardsRich Quote Link to comment https://forums.phpfreaks.com/topic/20323-accessing-a-specific-instance-of-a-_files-array/#findComment-89508 Share on other sites More sharing options...
isaaccs Posted September 10, 2006 Author Share Posted September 10, 2006 Hi,thanks for the reply. i'm kind of new w/ php.soo... here's the very basic processing script. it takes both of the uploaded files, displays their properties, and copies them to the storage directory.what i want it to do is: set the name of the file not derived from the local user's filename, rather from another value submitted as a $_POST (such that the user is basically renaming the file while uploading). there are two seperate fields being submitted (ie, name1 and name2) as post data from the form, in addition to the file upload.i also want image1 to have a different $file_dir than image2... but i don't know how to do that...basically i don't know how to differentiate between the two instances of the $_Files, because I want to take seperate actions on each one.---$file_dir = ".../httpdocs/cathyhull/artwork_upload";foreach ($_FILES as $file_name => $file_array) { echo "path ".$file_array['tmp_name']. "<br>\n"; echo "name ".$file_array['name']. "<br>\n"; echo "type ".$file_array['type']. "<br>\n"; echo "size ".$file_array['size']. "<br>\n"; if (is_uploaded_file($file_array['tmp_name'])) { move_uploaded_file($file_array['tmp_name'], "$file_dir/$file_array[name]") or die ("Couldn't complete"); echo "File upload complete!<br><br>"; }} Quote Link to comment https://forums.phpfreaks.com/topic/20323-accessing-a-specific-instance-of-a-_files-array/#findComment-89514 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.