Solved

php form submission losing data

Posted on 2012-03-12
11
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

734 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