Solved

Array in an Array

Posted on 2007-11-14
5
226 Views
Last Modified: 2008-02-01
When I am retrieving the value for the $_FILES super global I am getting Array returned.  How do I get the value of the elements inside the array to get returned?

<label for="file"><strong>File:</strong> <?php echo $details['file'] ?></label><br />

Form
<?php foreach ($cars as $car => $details) { ?>
<h3><?php print $car ?></h3>
  <label for="format"><strong>Format:</strong> <?php echo $details['format'] ?></label><br />
  <label for="rotation"><strong>Rotation(%):</strong> <?php echo $details['rotation'] ?></label><br />
  <label for="size"><strong>Size:</strong>
  <?php echo $details['724x90']; ?> &nbsp;
  <?php echo $details['300x250']; ?> &nbsp;
  <?php echo $details['160x600']; ?></label> &nbsp; &nbsp; &nbsp;
  <label for='other'><strong>Other:</strong> <?php echo $details['othertx'] ?> </label><br />
  <label for="layout"><strong>Layout:</strong> <?php echo $details['layout'] ?></label><br />
  <label for="bannerlink"><strong>Banner Link:</strong> <?php echo $details['bannerlink'] ?></label><br />
  <label for="file"><strong>File:</strong> <?php echo $details['file'] ?></label><br />
  <label for="dspecific"><strong>Deal Specifics:</strong> <?php echo $details['dspecific'] ?></label><br />
  <label for="disclaimer"><strong>Disclaimer:</strong> <?php echo $details['disclaimer'] ?></label><br /><br /><br />
<?php  }  ?>

0
Comment
Question by:taynet29
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 20

Assisted Solution

by:steelseth12
steelseth12 earned 350 total points
ID: 20283129
$_FILES['name_your_file_field']['name'] will give you the name of the uploaded file.

$_FILES['name_your_file_field']['type'] gives you the type

$_FILES['name_your_file_field']['size'] gives you the size

$_FILES['name_your_file_field']['tmp_name'] gives you the temporary name the file is stored in ...
For example to move the file to your server you would do

move_uploaded_file($_FILES['name_your_file_field']['tmp_name', 'destination/directory/name_of_file.jpg')

$_FILES['name_your_file_field']['error'] gives you the error if any
0
 
LVL 11

Assisted Solution

by:jgordos
jgordos earned 150 total points
ID: 20283138
Generally, you can print the entire array by just

print_r($a);

where $a is the array.

I'm not sure, exactly, what you're asking.

0
 
LVL 11

Assisted Solution

by:jgordos
jgordos earned 150 total points
ID: 20283153
0
 

Author Comment

by:taynet29
ID: 20283532
All the arrays are being printed on the "Work Order Review" page.  All I am asking is how do I get the variable to print as an array.  Keep in mind it is being stored as an Array in $details.  Then the $_FILES array.  As a result, <?php echo $details['file'] ?> prints ---> Array.  

What I have tried is
<?php if(isset($_FILES["file"][0])) ?>
<?php if(isset($_FILES["file"]["name"])) ?>
<?php if(isset($details["file"][1])) ?>
<?php if(isset($details["file"]["name"])) ?>

They all do not return a value.

Please let me know what I am doing incorrectly.  How do I print the file name?
0
 
LVL 20

Accepted Solution

by:
steelseth12 earned 350 total points
ID: 20283816
<?php echo $details['file']['name_of_field']['name'] ?> should do it
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question