Solved

php form submission losing data

Posted on 2012-03-12
11
218 Views
Last Modified: 2012-03-17
Hi

I have a website which works fine on my dev server, however once moved to a clients server it doesn't work correctly.

I have a form that allows the client to upload files/images/video etc to the website.

now the site is live on the clients server, he cannot upload images etc... I made the upload folder write enabled, but it still did not work.

After some investigation, it turns out that $_FILES['file'[['name'] is blank... even when a file is uploaded, so my script doesn't try to do anything with the file because it thinks there isn't one.

The form has text fields as well as file upload, and the script deals with the form in a single pass.

Is this something to do with accessing other data from the form before getting the file array?

weird how the exact same code works on my dev server...

Thanks
0
Comment
Question by:cycledude
  • 6
  • 5
11 Comments
 
LVL 36

Assisted Solution

by:Loganathan Natarajan
Loganathan Natarajan earned 500 total points
ID: 37709266
are you sure that your client server has same PHP version of your dev. server? you should have 4.3+
0
 
LVL 36

Assisted Solution

by:Loganathan Natarajan
Loganathan Natarajan earned 500 total points
ID: 37709275
also you could put text field and try to post the values and check the whether you can receive the value of text field???
0
 

Author Comment

by:cycledude
ID: 37709363
Hi  logudotcom

thanks for the replies.  I can confirm that the textual data is passed through and updates the database fine.

the 2 servers are slightly different versions of php,

dev: php 5.3.10

client: php 5.2.16
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 36

Assisted Solution

by:Loganathan Natarajan
Loganathan Natarajan earned 500 total points
ID: 37709465
on your form, did you put like this,

<form enctype="multipart/form-data">
0
 

Author Comment

by:cycledude
ID: 37709478
yes indeed

<form action='' method='post' enctype='multipart/form-data'>
0
 
LVL 36

Assisted Solution

by:Loganathan Natarajan
Loganathan Natarajan earned 500 total points
ID: 37709485
also another problem would be the memory limit on your client server..  check the limit .. make sure you have enough limit to upload and processs...

memory_limit = 51M

post_max_size = 50M

upload_max_filesize = 50M
0
 
LVL 36

Assisted Solution

by:Loganathan Natarajan
Loganathan Natarajan earned 500 total points
ID: 37709488
0
 

Author Comment

by:cycledude
ID: 37709542
Hi again

I have that one covered with a little php.ini file

<?php
upload_max_filesize = 200M ;
post_max_size = 200M ;
max_execution_time = 6000 ;
?>

Doing more investigation.... I have found something odd

there are a number of file inputs on the form, when I do a print_r($_FILES) it lists all of the file inputs except the one I am having trouble with!

could it be that this server is fussy about having a fileinput called 'file'?
0
 

Accepted Solution

by:
cycledude earned 0 total points
ID: 37709554
ok, I think I may have found a solution....

I moved the fileinput in question higher up in the code, and it is now being recognised...  so there must be some problem in  my html output that means the input is not being processed...

I will post an update once I have found out.
0
 

Author Comment

by:cycledude
ID: 37709787
right, I have checked the code and I can't see any problems (although that doesn't mean there aren't any) but at least I can now use the form to upload the file now...

there must be some malformed html in there somewhere which was causing problems along the line there somewhere...
0
 

Author Closing Comment

by:cycledude
ID: 37732216
thanks for the assists!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

829 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