Jump to content

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

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.