Jump to content

Storing array of files as variables


illuz1on

Recommended Posts

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

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

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.