Solved

php form submission losing data

Posted on 2012-03-12
11
214 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 36

Assisted Solution

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

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

Author Comment

by:cycledude
Comment Utility
yes indeed

<form action='' method='post' enctype='multipart/form-data'>
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 36

Assisted Solution

by:Loganathan Natarajan
Loganathan Natarajan earned 500 total points
Comment Utility
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
Comment Utility
0
 

Author Comment

by:cycledude
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
thanks for the assists!
0

Featured Post

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

772 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

13 Experts available now in Live!

Get 1:1 Help Now