Solved

php form submission losing data

Posted on 2012-03-12
11
217 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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…
This article discusses how to create an extensible mechanism for linked drop downs.
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 look for a specific file type in a local or remote server directory using PHP.

803 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