illuz1on Posted May 24, 2007 Share Posted May 24, 2007 Ok I asked this earlier but lemme try ask it in a better way: To make this short, this is the end process of my upload form, foreach($active_keys as $key) { @move_uploaded_file($_FILES[$fieldname]['tmp_name'][$key], $uploadFilename[$key]) or error('receiving directory insuffiecient permission', $uploadForm); } I want to obtain the 3 file's that have been upped's names that they were uploaded with.. and store those 3 filenames as $pic1, $pic2, $pic3 so as to insert them into a table.. Please I am desperate to get this working?? Thanks alot, Link to comment https://forums.phpfreaks.com/topic/52874-storing-array-of-files-as-variables/ Share on other sites More sharing options...
colombian Posted May 25, 2007 Share Posted May 25, 2007 What is $active_key? I would think a loop would do. for $i=1; $i<10; (or whatever limit of images they can upload at one time) $i++ $pic.$i = imagefile_name; //this is sudo code just giving you the idea. Hope it helps. Link to comment https://forums.phpfreaks.com/topic/52874-storing-array-of-files-as-variables/#findComment-261208 Share on other sites More sharing options...
illuz1on Posted May 25, 2007 Author Share Posted May 25, 2007 thanks for the reply, Below is a bit taken out of the code, I see what you saying I did think of that tried to do a foreach loop but didnt end up going right.. what kind of loop would it be? <?php $active_keys = array(); foreach($_FILES[$fieldname]['name'] as $key => $filename) { if(!empty($filename)) { $active_keys[] = $key; } } count($active_keys) or error('No files were uploaded', $uploadForm); foreach($active_keys as $key) { ($_FILES[$fieldname]['error'][$key] == 0) or error($_FILES[$fieldname]['tmp_name'][$key].': '.$errors[$_FILES[$fieldname]['error'][$key]], $uploadForm); } foreach($active_keys as $key) { @is_uploaded_file($_FILES[$fieldname]['tmp_name'][$key]) or error($_FILES[$fieldname]['tmp_name'][$key].' not an HTTP upload', $uploadForm); } foreach($active_keys as $key) { @getimagesize($_FILES[$fieldname]['tmp_name'][$key]) or error($_FILES[$fieldname]['tmp_name'][$key].' not an image', $uploadForm); } foreach($active_keys as $key) { $now = time(); while(file_exists($uploadFilename[$key] = $uploadsDirectory.$now.'-'.$_FILES[$fieldname]['name'][$key])) { $now++; } } foreach($active_keys as $key) { @move_uploaded_file($_FILES[$fieldname]['tmp_name'][$key], $uploadFilename[$key]) or error('receiving directory insuffiecient permission', $uploadForm); } ?> Link to comment https://forums.phpfreaks.com/topic/52874-storing-array-of-files-as-variables/#findComment-261548 Share on other sites More sharing options...
illuz1on Posted May 26, 2007 Author Share Posted May 26, 2007 no one? Link to comment https://forums.phpfreaks.com/topic/52874-storing-array-of-files-as-variables/#findComment-262218 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.