[nycphp-talk] File Uploads
Michele Waldman
mmwaldman at nyc.rr.com
Thu Jan 8 15:41:47 EST 2009
Funky. I'm thinking not visible iframe with a copy of the data that gets
submitted to a php script that slams the $_FILES into the $_SESSION.
Yuck!
Michele
_____
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of Elijah Insua
Sent: Thursday, January 08, 2009 3:30 PM
To: NYPHP Talk
Subject: Re: [nycphp-talk] File Uploads
On Thu, Jan 8, 2009 at 3:23 PM, Michele Waldman <mmwaldman at nyc.rr.com>
wrote:
form action="test.php" method="post" enctype="multipart/form-data">
<p>Pictures:
<input type="file" name="pictures[]" />
<input type="file" name="pictures[]" />
<input type="file" name="pictures[]" />
<input type="submit" value="Send" />
</p>
</form>
<?php
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name, "data/$name");
}
}
?>
When test.php is called $_FILES is defined. But, if I call another php
module right after $_FILES is no longer defined. Is there a way to capture
the value of $_FILES or make it persist?
$_FILES should be available through out a request as it is a super global
What I was trying was something like this:
form action="afunction();" method="post" enctype="multipart/form-data">
<p>Pictures:
<input type="file" name="pictures[]" />
<input type="file" name="pictures[]" />
<input type="file" name="pictures[]" />
<input type="submit" value="Send" />
</p>
</form>
function a_function()
{
rlxmlHttp=getXmlHttpObject();
if (rlxmlHttp == null)
{
document.getElementById("fnErrMsg").innerHTML = '*Browser does
not support HTTP Request';
}
else
{
rlxmlHttp.onreadystatechange=finishContact;
rlxmlHttp.open("POST","ascript.php",true); /* ascript.php using
$_FILES */
rlxmlHttp.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
/* rlxmlHttp.setRequestHeader('Content-Type',
'multipart/form-data'); */
rlxmlHttp.send(null);
}
}
The $_FILES variable no longer exist. But, $_FILES is no longer defined.
Does anyone have any creative ideas?
Michele
You may want to make sure, but I'm quite positive that you cannot upload
files using 'AJAX', look to flash or an iframe if this is really important.
-- Elijah
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20090108/406e6dc0/attachment.html>
More information about the talk
mailing list