Solved

Array in an Array

Posted on 2007-11-14
5
221 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
  • 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

706 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now