Jump to content

Recommended Posts

hi

im accessing it as i would any other POST variable

but i'm not getting any outpution

 

what's happening is that im building a multifile upload thing and for each file i select, i hide the file input element and add another one in the same place to look like it's always the same one.

i'm give it the name (its not me - following a tut and tweaking). the new name for each input is

name="fileArray[]"

 

what does this code do? does it automatically create

fileArray[0] = "name of the file selected"; 

?

i've tried outputting

$_POST[fileArray[0]];

with no success :/

Link to comment
https://forums.phpfreaks.com/topic/202662-whats-this/#findComment-1062328
Share on other sites

<?php 
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html><head><title>title</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<meta http-equiv="Expires" content="0">
<link href="../css/panel.css" rel="stylesheet" type="text/css">
<link href="../css/photos.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<? include 'phpincludes/menu.php' ?>
<div id="sectionTitleDiv">Photos</div>
<form name="uploadForm"
  method="post"
  enctype="multipart/form-data">
<table id="mainTable" cellspacing="0" cellpadding="0"><tr>
<td id="selectorTd" valign="top">
<div id="fileSpecs">Allowed extension: <b>jpg</b><br />Max file size: <b>250Kb</b><br />Max image dimensions: <b>100px</b>(width),<b>150px</b>(height)<br/>Max images: <b>30</b></div>
<div>
<input type="file" name="fileArray" id="inputElement"/>
</div>
</td>
<td id="galleryTd" valign="top"><?php print_r($_POST); ?></td></tr>
<tr><td colspan="2" class="footer"><input type="submit" value="Save"/></td></tr>
</table>
</form>
</div>
</div>
</body>
</html>

 

edit: that doesn0t even work, without an array. i simplified for simplification

edit2:i kept out the javascript to hide the input field and replace it with another one. using jquery. i dont think it's relevant, cause with that code simply changing to form-data breaks the post anyway

Link to comment
https://forums.phpfreaks.com/topic/202662-whats-this/#findComment-1062446
Share on other sites

Yes this works on every element:

 

<input type="checkbox" name="checked[]">

<input type="checkbox" name="checked[]">

<input type="checkbox" name="checked[]">

<input type="checkbox" name="checked[]">

<input type="checkbox" name="checked[]">

<input type="checkbox" name="checked[]">

<input type="checkbox" name="checked[]">

<input type="checkbox" name="checked[]">

<input type="checkbox" name="checked[]">

 

print_r($_POST['checked']);//returns an array of all those which are checked.

Link to comment
https://forums.phpfreaks.com/topic/202662-whats-this/#findComment-1062497
Share on other sites

well, this does not work

<form name="uploadForm" method="post" enctype="multipart/form-data">
<input type="file" name="fileToUpload"/><br/>
<?php print_r($_POST['fileToUpload']); ?><br>
<input type="submit" value="Save"/>
</form>

...so im guessing either u cannot call a file directly through post, or there's a bug with the enctype

Link to comment
https://forums.phpfreaks.com/topic/202662-whats-this/#findComment-1062504
Share on other sites

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.