473,465 Members | 1,747 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

PHP file upload problem

Hi all,

Heres a strange problem i am running into running Php4.2.2. I am
uploading a file using a post and when i receive the file on my share
the file adds some more records to it ( These are duplicate records
in the file). Dont know whats happening all input is appreciated.

Heres the code:
main.php
<?
....
echo "<FORM ENCTYPE='multipart/form-data' ACTION='abc.php'
METHOD=POST>";
echo "<INPUT TYPE=hidden name=MAX_FILE_SIZE value=1000000>";
echo "<INPUT NAME=userfile TYPE=file>";
echo "<INPUT TYPE=submit VALUE='Continue'>";
echo "</FORM>";
....
?>

abc.php

<?
....

$file = $HTTP_POST_FILES['userfile']['name'];

// this shows more than actual size;

echo $HTTP_POST_FILES['userfile']['size'];
if (is_uploaded_file($userfile)) {
copy($userfile, "/tmp/$file");

.... }

?>

Please advise.

Thanks
S
Jul 16 '05 #1
2 3822
phantom wrote:
Heres a strange problem i am running into running Php4.2.2. I am
uploading a file using a post and when i receive the file on my share
the file adds some more records to it ( These are duplicate records
in the file). Dont know whats happening all input is appreciated.

Heres the code:
main.php
<?
...
echo "<FORM ENCTYPE='multipart/form-data' ACTION='abc.php'
METHOD=POST>";
echo "<INPUT TYPE=hidden name=MAX_FILE_SIZE value=1000000>";
echo "<INPUT NAME=userfile TYPE=file>";
echo "<INPUT TYPE=submit VALUE='Continue'>";
echo "</FORM>";
...
?>

abc.php

<?
...

$file = $HTTP_POST_FILES['userfile']['name'];

// this shows more than actual size;

echo $HTTP_POST_FILES['userfile']['size'];
if (is_uploaded_file($userfile)) {
copy($userfile, "/tmp/$file");

.... }

?>
Could you give us a sample of the files you're trying ( a before version and an
after version )?
You're sure that the new file is replacing the old one in /tmp (in other words,
you're sure that there's no error when the $userfile is being copied over
/tmp/$file)? If not, check the time.
Why did you code the last 2 lines like this:
if (is_uploaded_file($userfile)) {
copy($userfile, "/tmp/$file");


instead of using $HTTP_POST_FILES?

--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 16 '05 #2
>
Could you give us a sample of the files you're trying ( a before version and an
after version )?
You're sure that the new file is replacing the old one in /tmp (in other words,
you're sure that there's no error when the $userfile is being copied over
/tmp/$file)? If not, check the time.
Why did you code the last 2 lines like this:
if (is_uploaded_file($userfile)) {
copy($userfile, "/tmp/$file");


instead of using $HTTP_POST_FILES?

Before i mention about the files there is something strange i ran
into. On changing the files extension to abc.php3 from abc.php it
uploaded the files in the tmp directory correctly. The 3 extension is
for php version 3 i am guessing which was originally residing on the
server (we moved to php 4 lately a little bizarre) . Yeah so the point
is that the php3 extensions work fine whereas php itself does not. I
ran a php info() on the files labelled as php3 and as php but could
not find much differences. For one thing I am sure the problem lies
with the php-module its picking up... Shoould I be looking at
something else too. Please let me know

Now to answer about the files before and after.
Before its a simple txt file

James Douglas Buffalo NY
Rick Yale JacksonVille FL
.....

the records get messed up in no known format and so happens

as
James Douglas Buffalo NY
Rick Yale JacksonVille FL
.....

J Douglas Buffalo NY
Rick Yale JacksonVille FL

It is to note that the repetitive record drops some charactes as the
James turned J.

Thanks much
S
Jul 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
3
by: Bijoy Naick | last post by:
I've written a simple file upload user control in VB .NET. It comprises of an InputFile HTML Server Control, an Upload button and a message label. User clicks on the Browse button of the...
6
by: tshad | last post by:
I have an upload file input as: <input id="MyFile" style="width:300px" type="File" runat="Server"> This works fine, but I find that if my page doesn't pass validation during postback, the page...
18
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't...
4
by: Matt Jensen | last post by:
Howdy I've got a rather strange issue occuring. I used forms based .NET authentication, although I'm also setting some session variables when people login. However, I've found when people use...
5
by: William LaMartin | last post by:
I have a VB ASP.Net application where the user can upload a file using the FileUpload server control. I also want a thumbnail to be created for this file. Unfortunately I can see no means to...
4
by: riteshjain82 | last post by:
Hi, Please go through this: I am having a file (default.asp) on which i am taking many details from a user before mailing it to someone. I have also provided the user with a facility of...
6
by: Vic Spainhower | last post by:
Hello, I am trying to do a FTP file upload which works fine on my localhost but on my ISP server it fails. I can't seem to find where I can go to find the specific cause of the failure. In both...
7
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
1
by: pbd22 | last post by:
hi. i have been posting this here and elsewhere a lot and can't seem to get resolution on this problem. i have been trying to upload files using a hidden iframe to a asp.net/vb.net form. the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.