Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




From POST To GET: $_FILES Empty


I'm passing the code from $_POST to $_GET.

I've a page upload using $_FILES. when the page was in $_POST, it worked
fine, but now, in $_GET, the $_FILES is empty.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
FIle Uploads: Empty _POST And _FILES Arrays When File Too Large
Uploading of files.. AFAIU from the manual, if a file is larger than the
size defined in the form or larger than upload_max_filesize in php.ini,
that _FILES['file']['error'] should hold an INT error code.

The file upload system is working fine if the file is smaller than the
defined size, but if it's larger, then both the _POST and _FILES arrays
are completely empty:

array(0) {
}

I can obviously check to see if $_FILES is set and contains elements,
but I was hoping for more specific error handling (reason as to why the
upload failed).

Has anyone else encountered this? Any info welcomed =)

Empty Variables And 4.21 (POST/GET)
With global variables set to on, I always had the following in my script to make sure variables had a default value:

if (empty($var)) {
$var = 1;}

Now with 4.21, I changed it to:

if (empty($_GET['var'])) {
$var = 1;}

The problem is sometimes I use GET and sometimes I use POST. With global variables on it didn't matter. Now it does. Is there a way to do this? When I try if (empty($_GET['var']) || empty($_POST['var'])), it doesn't work because one or the other will always be empty at any one time.

Query About Empty POST Arrays
I started programming in PHP recently and have a query about empty
$_POST arrays. I can see two scenarios when this could happen.

1. When some tries to directly load the page to which data is being
posted (for example, opening www.foo.com/xyz.php directly when a form
action is xyz.php)
2. When the user clicks the submit button without entering anything.

I am aware that Javascript validation can take care of the second case,
but it's unreliable. What is the accepted way of handling the above
situations on the server side?
Do I just reload the calling page if the array is empty?

Dont Want To Post Data If Row Field Is Empty
I dont want to post the $row ['thumbnail'] data in this string if the field is empty. Can someone help me out? ....

Cannot Read Information From Form Using POST Or GET ($_Post Is Empty)
I am having problems in my php code. I am relatively new to php but I
know some basics.

This is the problem:

when i try to echo some information that is typed into form back to
the screen i get absolutely nothing. It seems like $_POST['name'] is
an empty string, along with $_POST and $_GET['name'].

I looked around to see if someone else had the same problem and found
that some people's code didn't work because of IE6. but i also tried
mine on Netscape and i got the same problem.

So why is $_POST empty after posting information. Even $_GET was
empty.

all of those returned empty

echo $_POST;
echo $_POST['name'];
echo $_GET['name'];

here is the code:
the code was originially meant to send an email but i commented the if
statement out to see why it wasn't working

<html>
<head><title>Feedback</title></head>
<body>

<?php

// Handle POST method.
//if ($_POST)
//{

$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];

// Compose simple text message:
$message = "Message from $name
($email)

Comments:

$comments";

// Send message to bob@microsoft.com
mail("email@email.com", "Feedback", $message);


Ftp_nlist Returns False For Empty Directory Instead Of Empty Array
In an application installed with PHP5 it looks like ftp_nlist() returns
false if the directory is empty, instead of an empty array as it should
according to the manual. On the original server with PHP4 it works as
expected.

Is this a bug, or an undocumented change in PHP5, or a setting that
could be changed somewhere?

Each $_FILES
nothing shows up when I run this code from a form? I'm trying to cycle through what needs to be uploaded. I have 5 file inputs.

echo "Values submitted via FILESbr />
";
reset ($_FILES);
while (list ($key, $val) = each ($_FILES)) {
echo "$key => $val<br />
";
}

Put $_FILES Into A Session
I'm trying to get my $_FILES arrays into a session because I want to
move the files later to a specific directory (ie after I get a result_id
from a sql insert). No problem putting the variables in a session but I
can't move $_SESSION['userfile']['tmp_name'] anymore.
$_SESSION['userfile']['error'] is 0 so I don't really see what could be
the problem....

$_FILES/forms
Is there any way of setting the $_FILES array without actually uploading a file through http upload?

I ask because I want to send a file that already exists on my server to be handled by my script that deals with normal uploads. The reason the file has to be sent in the $_FILES array is that this is how the upload script receives and processes files and it is zend encoded so I can't edit it!

$_FILES Superglobal: Where Is The Filename
$_FILES superglobal does not work for me, i use php 4.1.1
if i look in $_REQUEST i can finde the path to the uploaded file, but how do i get the name and mime type of that file?
thanks for any help

$_FILES[] - Upload Variable Name
Is there a predefined variable name for a file when you are uploading to a server? I need to know the actual file name, Is there a way or will i have to use REGEX to parse out the name from the end of the path?

Can't Upload File To $_FILES
I'm trying to figure out why I can't upload a file in php.
I'm trying it locally on a windows XP machine running Apache 2.2 and
PHP 5.2.1.
That is I am running the browser/server on same machine to test with.
I also tried it on a remote linux server, though in that case I'm not
sure what the s
config settings where, except that it does have PHP and I get the same
results.

Are there any releevant apache settings ? I have not come accross any.

Below is my script, results, and config settings.

=------------------------------------------------------

<html>

<body>

<?php

if ($_SERVER['REQUEST_METHOD'] == 'GET') { ?>
<form enctype="mutlipart/form-data" method="post" action="<?php echo
$_SERVER['SCRIPT_NAME'] ?>" >
<input type="file" name="document"/>
<input type="submit" value="Send File"/>
</form>
</body>
</html>
<?php }
else
{
echo "FILE=";
print_r($_FILES);
echo "</br></br>POST=";
print_r($_POST);
}

--------------------------------------------------------

on a post I get an empty $_FILES object and something in the $_POST
variable from the above prints:

FILE=Array ( )

POST=Array ( [document] =feedblitz.txt )


# my php config file has these settings which I also verified with
phphinfo()

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default
if not
; specified).
upload_tmp_dir = "c:playsoaptest";

; Maximum allowed size for uploaded files.
upload_max_filesize = 5M

Clearing Out The $_FILES Variable
I posted yesterday and no one answered; I"m wondering if this list is
having tech difficulties....

I'm having trouble with my $_FILES variable. What my program does is
allow a person to have an image file on their web page. So if there
is an upload, it processes it (resizes it if need be). If they choose
to keep their old picture, it isn't supposed to do anything, but it
still seems to be passing in a $_FILES variable ANYWAY! I did some
wrangling to have it process the image based on another field, a
checkbox that is checked showing the existing image and it indicates
to keep it if it's on ($processsimage="no")

But why is it still passing in a value for $_FILES['thefield'] anyway
when there isn't anything in that field for upload? It poses a
problem when they are adding a page that might not have an image on it
(it's a content manager).

I hope someone can help with this perplexing problem. I can't go back
to using globals as I am on a quest to get away from using globals
because it's a security risk, and I've been hacked already, and my ISP
would like me to change my evil, global ways and so would i!

$_FILES[var][size] Question
I'm uploading a file to the server - I check the $_FIILES[var][size]
variable to check for exceeding a certain limit (250KB in this case) _
I notice that when I try to upload files of 500KB or 900KB [size]
holds the value and I can check it - however, if I try to upload a
2300KB file [size] is 0 - does anyone know what might be causing this?
Why doesn't that large of a file also get recorded in the [size]
variable?

$_FILES Does Not Work On Windows
I'm having a PHP problem. Whenever I use the $_FILES superglobal to upload files via a form, it never seems to work when I run it on any Windows system. However, when I run it on my Mac, the image uploads just fine with the same script. What could the problem be?

$_FILES['uploaded_file']['type']
I want to check the file type so I can add condtion to my image resize script.
I have read that  $_FILES['uploaded_file']['type'] is unreliable.
Is there another way to determin the file type of a file before making copies of it?

Help With Str_replace & $_FILES Arrays Need To Loop?
Ok I am trying to get these loops figured out

I have 10 files being uploaded- $_FILES['pic1-10']

I need to run str_replace on all 10 to eliminate any oddities " ","%20"
to clean up the filenames before inserting names in db.

foreach ($_FILES as $n) {
$name=$n["name"]
str_replace( " ", "",$name)

now how do I get it read back into $_FILES['pic1']['name'] and continure on
to pic2?

Full Local Path Of $_FILES
When processing a standard file upload form, is it possible to save the full local path of the file? If there is an arror on the form, I want to re-display the file name in the field when it reloads. This data doesn't seem to get posted. All the local path info is stripped off.

Fill $_FILES Argument From XML Parser
I've a function asking for a $_FILES argument:

function insertarticle($particle,......,$pUserID,$pOptions, $files){
in this function I do add the record and then save the files in a
subdirectory specific on some datas.

This function is used by my "insert" form, letting the user to select images
files to upload with <FILE> html tag.
The files to upload are then passed to the $files like this:
insertarticle(1884,......,4,$Options,$_FILES);

for mantainance purpose, I avoid as much as possible to have the same code
in 2 different pages. Also, using actually this function to add a record in
the database (quite complex code) and saving files from a form, and using
the same function to add records from an XML parser, I can't send images
files to the function.

My parser can save the images files on the server's directory, but how to
pass $files parameters in order to save those files ? It's there any way to
take the string containing the base64 image code (I do actually save it
locally) and put it in a $_FILES array for passing it to the function ?

Access The $_FILES Array Without A Re-loading?
My user is uploading an image file with a files variable (userfile) in a form. After he's selected his image file, I want to be able to display it so that he can see what he's about to upload.

Is there anyway I can access the $_FILES arrray so that I can get $_FILES['userfile']['tmp_name'] so that I can find his image file so that I can then display it? - e.g. using javascript with an onclick or mouseover event. Without having to reload the script or load a new script?

$_FILES['File']['type'] Returns Nothing
I have an MP3 Upload site, but when a user logs in and uploads a file, more than half of the time the MP3's MIME type returns absolutely nothing!

I don't think it's the code, because some of the music uploads well, it's just about 65% has no MIME! Any explanation?

$_FILES From The Server - Not Local Machine
I'm just playing with someone else's code and was wondering how to get details of a file that's already uploaded to my server into the $_FILES super global.

the code I have is: ...$uploadedFileName = $_FILES['filename']['name'];
if($_FILES['filename']['size'] > $maxSize)
{...
all the checks are done using this and I just want to parse all this info without the user having any control / knowledge of it at all.

It's for an image upload script which has been built already, but I want lots of differing quality thumbnails to be generated, but the current code keeps asking the user to input size variables and path details to upload a file from their local machine.

Passing $_FILES Array Into Function
I would like to create a function that uploads files and I am running into a roadblock using the superglobal $_FILES variable. Code:

File Field Validation $_FILES??
I have the following code that validates my form fields. I have a file field called file that I cant figure out how to validate. Code:

Any Reason Why $_FILES['userfile']['error'] Wouldn't Be Populated?
I am in the middle of writing an image upload script and am limiting
the size of uploads via upload_max_filesize. This all seems to be
working well, and if I try and upload a bigger file then I get an
UPLOAD_ERR_INI_SIZE sat in $_FILES['userfile']['error']. All hunkey
dorey.

However, in my testing there are one or two large files that cause
problems. PHP appears to abort the upload early as it should, but when
my script runs, $_FILES isn't populated at all?!

I have tried to narrow down the difference in these file but I can't
seem to find anything definate. All the ones that fail are AVI or WMV
files if that gives any clue, but even if I rename them to MPG (others
of which work ok), and check the MIME type being sent up has also
changed to mpg, then they still fail as before. I have sent bigger and
smaller files all ok, so it's not size. I can't see anything in the
filename itself that would cause problems.

$_FILES[$field_name]['tmp_name'] Dirname Missing Trailing Slash
I've beat my head every way I can think of against this wall. Maybe
someone here just knows the answer.

I'm testing an upload class on my laptop WAMP server. When I run the
test script, everything is fine. When I put together my own form and
test uploading the same file, it fails because the
$_FILES[$field_name]['tmp_name'] value is missing the trailing slash at
the end of the temp dir name, so that the temp name looks like this:

c:/wamp/tmpphp11.tmp

instead of:

c:/wamp/tmpphp11.tmp

as in the packaged demo script.

I know that this value is set in php.ini. But that can't be the
problem as everything works fine in the demo script. As far as I can
discern, this value -- the temp dir name -- is handled internally by
PHP and not affected by the script, so I can't even check the value and
add the slash if it's missing. So my question: does anyone know why
the trailing slash is being dropped in my script?

I've tried every variation I can think of. I even tried to replicate
my error in the demo script by changing some of its form settings. I
can't get the two script to do the same thing with this
$_FILES[$field_name]['tmp_name'] value, even though everything else
should be equal.

All I can figure is that it has something to do with the forms' x/html
settings. The only other significant different between the two scripts
is that mine posts to itself and the demo to a separate page.

Anyway, if you can answer this for me, you'd really make my day! :)

PHP Session Is Empty And Session File Is Empty
I am trying to save a SESSION variable which looks to succeed because right after I print it out to verify it. I do so as follows:

session_start();
<snip>
$_SESSION['security_code'] = $code;

The problem is that I submit a form on the same page and I need to check if the $_SESSION['security_code'] == $_POST['security_code'] however this condition is always false because $_SESSION['security_code'] is empty.  I also checked the security files that are created in the PHP 'save_path' directory and it appears to be creating an empty session file.

Can anyone suggest anything here?  Also prior to the condition, I also do a session_start() and that doesn't help either.

I got this code from a open source area and on that web site, if I test it it works fine.  On my localhost it does not work.  I'm not sure if I'm missing some configuration or whether PHP 5.2.2 has problems with sessions.

Post And Redirect With Post Data
The solution we have though up is the following:

1. The user fills in data in a form and hits submit
- This submits (POST) to another page (redirect.php)
2. redirect.php adds more POST data to POST and then submits all this POST data to another page (offsite [payment portal])

The reason why we have to do this is for someone who knows our to read html source code, could easily find the sucessful page which will then do the processing we need to do on our side. Which means freebeis.

Calling A Post Script From A Post Script; Curl Works But ...
I am trying to call a php script B from script A.

However, when I do this with curl everything works fine except the url of the script is the url of script A. How can I make the URL the URL of script B.

Is this possible with curl?

PHP Post, Then HTML Post?
Using PHP, I want to POST or GET some variables to a second php page.
This, I already know how to do.

However, on the second php page, I want to use a simple, standard HTML
form using the standard form-submitting method such as:

<form action="https://orderpage.ic3.com/hop/orderform.jsp"
method="post">

whereupon both sets of variables --- the earlier variables that were
POSTed or GETted to the second page, along with the standard form
variables derived within the second page --- will be POSTed to the
above URL.

In the second page, might I actually translate the received variables
into actual HTML code? For instance, if my first page POSTed the
variable xyz to the second page, then might the following code on the
second page receive that variable and then include it when the second
page's "Submit" button is pressed?

<? $xyz=$_POST['xyz']; ?>
<INPUT TYPE="HIDDEN" NAME="xyz" value="<?=$_POST['xyz']?>" >

Or how, otherwise, might this be done?

Using Empty And &&
Im checking to see if all of these are empty I have to do something:

if (empty($_POST['phhome'] && $_POST['phcell'] && $_POST['phwork'] &&
$_POST['email'])) {

But this isnt working and putting empty() around each didnt either. What
I'm I not seeing?

Help With Empty()
this is my php:

$pro1=addslashes($_POST['pro1']);
$pro2=addslashes($_POST['pro2']);
$pro3=addslashes($_POST['pro3']);
$pro4=addslashes($_POST['pro4']);
$pro5=addslashes($_POST['pro5']);

for ($i=1;$i==5;$i++){
if (!empty(${'pro'.$i}))
$pros.=${'pro'.$i}."";
}
echo nl2br($pros);

$pros return nothing, although $pro1 and $pro2 contain certain value...

Using If Empty
I am trying to use the if empty statment to make sure that every input box has been filled, the code looks like this. Code:

if(empty($inputbox)){
print "you did not fill in a box.";}

This works fine but there is about 20 input boxes and there must be an easier way to insted of repeating this 20 times.

Empty If / Else ?
I have never done this, but I have an if/else statement, and if I don't want anything to happen in the if statement, should I leave it empty or is there something that I could add???

A simple example (my actual code is much longer):
<?php
if(empty($_POST['fname'])){

}else{
     $name = $_POST['fname']
     mysql_query("INSERT INTO name(`first`) VALUES ('$name'));
}?>

Testing For Empty Set?
basically, i want to query my db and see if the user has input a valid #.... if it matches a record im my table 'plu_coupons' then i will execute the code that allows a user to proceed... if the number input by the user does not match any of my records, he/she will be redirected to the sign-in page...

How To Empty An Array?
I've got a nested array, which I populate while processing and formatting results from a query. When I print the contents of the array I want to clear it so that I can use it again in the next iteration of the loop without the stuff I've printed still in it. Is there a straight forward way to do this? I've tried re-declaring it but that doesn't empty it.

Empty Sessions
When sessions are created by my message board or any other script. The sessions I can see inside the /tmp folder but when I open em up with pico I see NOTHING! no session variables or anything!!

I have been tryin to figure this out forever here is my php.ini configuration for sessions

[Session]
session.save_handler = files ; handler used to store/retrieve data
session.save_path = /tmp ; argument passed to save_handler
; in the case of files, this is the
; path where data files are stored
session.use_cookies = 1 ; whether to use cookies
session.name = PHPSESSID
; name of the session
; is used as cookie name
session.auto_start = 1 ; initialize session on request startup
session.save_handler = files ; handler used to store/retrieve data
session.save_path = /tmp ; argument passed to save_handler
; in the case of files, this is the
; path where data files are stored
session.use_cookies = 1 ; whether to use cookies
session.name = PHPSESSID
; name of the session
; is used as cookie name
session.auto_start = 1 ; initialize session on request startup
session.cookie_lifetime = 0 ; lifetime in seconds of cookie
; or if 0, until browser is restarted
session.cookie_path = / ; the path the cookie is valid for
session.cookie_domain = ; the domain the cookie is valid for
session.serialize_handler = php ; handler used to serialize data
; php is the standard serializer of PHP
session.gc_probability = 1 ; percentual probability that the
; 'garbage collection' process is started
; on every session initialization
session.gc_maxlifetime = 1440 ; after this number of seconds, stored
; or if 0, until browser is restarted
session.cookie_path = / ; the path the cookie is valid for
session.cookie_domain = ; the domain the cookie is valid for
session.serialize_handler = php ; handler used to serialize data
; php is the standard serializer of PHP
session.gc_probability = 1 ; percentual probability that the
; 'garbage collection' process is started
; on every session initialization
session.gc_maxlifetime = 1440 ; after this number of seconds, stored
; data will be seen as 'garbage' and
; cleaned up by the gc process
session.referer_check = ; check HTTP Referer to invalidate
; externally stored URLs containing ids
session.entropy_length = 0 ; how many bytes to read from the file
session.entropy_file = ; specified here to create the session id
; session.entropy_length = 16
; session.entropy_file = /dev/urandom
session.cache_limiter = nocache ; set to {nocache,private,public} to
; determine HTTP caching aspects
; cleaned up by the gc process
session.referer_check = ; check HTTP Referer to invalidate
; externally stored URLs containing ids
session.entropy_length = 0 ; how many bytes to read from the file
session.entropy_file = ; specified here to create the session id
; session.entropy_length = 16
; session.entropy_file = /dev/urandom
session.cache_limiter = nocache ; set to {nocache,private,public} to
; determine HTTP caching aspects
session.cache_expire = 180 ; document expires after n minutes
session.use_trans_sid = 1 ; use transient sid support if enabled
; by compiling with --enable-trans-sid

PLEASE I NEED HELP!!

my /tmp is chmoded to 777 and I have tried everything...

I know it isnt my forums because they worked on another server I transfered from and also it affects more than just the forums... every scripts that uses sessions is affected...

Empty Array?
I have a query that selects some data from a table based on the current ID
selected.

If the query does not return any results, I want it to continue to another
query that will insert a record into the table.

Below is what I have...but it will not insert anything if the first query...

PHP_AUTH_USER Is Empty
I use basic authentication in Apache. I like to use the global variable
$_SERVER['PHP_AUTH_USER']. Unfortunately this variable is empty/no
availabe. Same with PHP_AUTH_PW. AUTH_TYPE is working and states
"Basic".

PHP Variables Are Always Empty
I'm trying to write a PHP script which allows to enter an username and a
password and to click two buttons.
If I start my PHP scripts 'mytest.php' I see the two input fields and the
two buttons. However if I enter something to the input fields and press a
button the echo commands show nothing.

======

PHP script 'mytest.php'
-----------------------

<?php
session_start();

if (!isset($_SESSION['auth_ok'])) {
$_SESSION['auth_ok'] = false;
}

echo "$user <br>";
echo "$pass <br>";
echo "$button1 <br>";
echo "$button2 <br>";
echo "$auth_ok <br>";

if (isset($button1)){
echo "Button 1 has been pressed<br>";
$auth_ok = true;

Php Shows Up Empty
I havea problem with a php page, everytime I call it it presents me
with an empty page, with only

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-
1252"></HEAD>
<BODY></BODY></HTML>

as if have only made an empty php-page, I cannot figure out what the
problem is, can anyone help me. (I have made a test page with only <?php ?> run it and it gave me the exact same result)

Empty Variables In 4.2.1+
I have a site where I check to see if a variable isset to see which file I include on a page - the URL would be something like: http://www.domain.com/?s

Then in the PHP file I check to see: PHP Code:

Htaccess Must Be Empty
I am moving some php scripts to a new host. While getting to know the
server, I ran into a strange problem.

If I add a .htaccess file, or more specifically: a .htaccess with
content, to a folder, requesting (html and php) files from that folder
results in internal server error messages.
If I upload an empty .htaccess file, all is fine. Then phpinfo() tells
me I am using Apache/1.3.27.

$_POST Of Empty Vs 0 Value
working on LINUX I found that both empty($_POST['foo']) where $foo = 0 or &foo = empty gives me TRUE. I.e. I can not distingush between 0 and empty value - I need it for the text box value. What is the solution?

Empty The Database
Is there a command that will empty or delete all the information in a database but keep the structure of the database so new information can be added to it?

Empty Lines
i read the filr into an array using file().
some of the lines are empty. i would like to output the file but
ignoring the emnpty lines.

Empty Form
Say I have a form, a really long form, is there a way to check if all the fields in the form are empty without saying a million if statements?

Empty Vs. Isset
I have a user form where users input float values or integers. If I want to see if no value has been input, I use the empty() function.  But if I want to see if users HAVE input a value that is a float or an integer, what function should I use?

How To Empty An Array??
I have an array being created a number of times with in a loop, before it is created I want to check if it empty and if it isn't then clear it down. How do I do this?


Copyright © 2005-08 www.BigResource.com, All rights reserved