473,748 Members | 2,574 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

strange problem with upload file

I've created a page with a form to upload files:

<h1>Upload di un file</h1>
<form enctype="multip art/form-data" method="post" action="do_uplo ad1.php">
<p><strong>Fi le da trasferire:</strong><br>
<input type="hidden" name="MAX_FILE_ SIZE" value="1000000" >
<input type="file" name="img1" size="30">
</p>
<p>
<input type="submit" name="submit" value="Upload File">
</p>

and this is the page to upload file:

<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILE S should be used
instead
// of $_FILES.
$uploaddir = 'dir';
$uploadfile = $uploaddir . "/" . $_FILES['img1']['name'];
print "<pre>";
if (move_uploaded_ file($_FILES['img1']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES );
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES );
}
print "</pre>";
?>

if i upload an image, it appeare full of artifacts, an example
original image:
http://www.alientech.it/banners/eurochibi_120x600_0.gif
upload image:
http://www.alientech.it/upload/eurochibi_120x600_0.gif

another example with a text file: original file

aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
a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-----------------------------7d4195179061-----------------------------7d4195
1790612
Content-Disposition: form-data; name="img1"; filename="C:\fe de_grande.txt"
Content-Type: text/plain

aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaa
aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaa

Why all this?
Thanks
Andrea
Jul 17 '05 #1
1 2877
Muppy wrote:

I've created a page with a form to upload files:

<h1>Upload di un file</h1>
<form enctype="multip art/form-data" method="post" action="do_uplo ad1.php">
<p><strong>Fi le da trasferire:</strong><br>
<input type="hidden" name="MAX_FILE_ SIZE" value="1000000" >
<input type="file" name="img1" size="30">
</p>
<p>
<input type="submit" name="submit" value="Upload File">
</p>

and this is the page to upload file:

<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILE S should be used
instead
// of $_FILES.
$uploaddir = 'dir';
$uploadfile = $uploaddir . "/" . $_FILES['img1']['name'];
print "<pre>";
if (move_uploaded_ file($_FILES['img1']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES );
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES );
}
print "</pre>";
?>

if i upload an image, it appeare full of artifacts, an example
original image:
http://www.alientech.it/banners/eurochibi_120x600_0.gif
upload image:
http://www.alientech.it/upload/eurochibi_120x600_0.gif

<snip>

I don't see anything wrong with your code. I can't see the uploaded gif at the
link above. In fact it appears as though there is no "upload" directory at
alientech.it.

How are you viewing the files afterwards? In the text file it looked like the
file was being sent twice.

Regards,
Shawn
--
Shawn Wilson
sh***@glassgian t.com
http://www.glassgiant.com
Jul 17 '05 #2

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

Similar topics

3
2104
by: Courtney L. | last post by:
I tried to search for this issue on the group, but don't even know where to start, so here's my problem. We have a very simple form which has a file upload box. Upon submit the file should be uploaded (using the copy function, from the server's temp directory to our final directory), the database should be updated, and the user should be notified of success/failure. In that order. When we test it at the office, and even from a dial-up...
1
1953
by: Kareem Badr | last post by:
I was having permission problems, so I'm using a test file to make sure uploading works. upload.php successfully uploads a file to the images/bookcovers dir: <html> <form method="post" enctype="multipart/form-data" action="upload.php"> <input type="file" name="userfile"> <input type="submit" value="submit"> <input type="text" name="eh" value='meh&lt;'>
5
1290
by: Shapper | last post by:
Hello, I just upload my web site to my hosting server and when I access it I always get an error: "Redicterion limit for this URL exceeded. Unable to load the requested page" Does anyone has any idea what is going on?
2
1487
by: Alex Grefu | last post by:
Hello everyone! I have a problem that it's gonne drive me crazy... I have an intranet web application that has an upload module. I did it, test it and it's working on my development machine(windows xp; vs 2005; asp.net 2.0), but when I moved the completed application to the production machine (windows 2003 server; asp.net 2.0), the upload module doesn't work anymore: I randomly receive this error: Cannot access a closed file. mscorlib: I...
0
1150
by: Oscar Thornell | last post by:
Hi, I use the xsd.exe tool to generate C# classes from an Xml schema. We can call the root object "MyObject" for simplicity... I expose "MyObject" in a web service like this... public void Upload(MyObject obj){..} When I set a web reference from a client to my web service the generated WSDL exposes the type "MyObject" as "obj" i.e. the variabel name I use in
3
1659
by: mikecom | last post by:
Hi Maybe there is an oracle out there who can help. I have an aspx site and a simple fileupload control on it. Everything works fine except: I can reproduce an 404 error when trying to upload some files. It only happens when trying to upload PDF Files, and not on every PDF File.
2
1675
by: ELINTPimp | last post by:
Hello all, Have a really interesting problem (at least to me) with my upload_file() function. I have it working now, with a bit of a work around, but would like to know what everyone thinks in regards to this being a bug or perhaps my ignorance. Basically the function takes two arguments, one is the desired file path I want the upload file to be moved to, and the second is an arbitrary integer. If the file doesn't already exist, the...
3
2296
by: macca | last post by:
Hi people! I'm having a problem with a file upload script that I'm writing. It works with Firefox but not Internet explorer. When the form is submitted(to it's self) it check for a file upload using this: $room_type = $_POST;
1
2290
by: pitjpz | last post by:
We have moved our Database to another server. The server it was on used SQL 4 and the new one its on now uses SQL5 the only problem we can find is that when you attempt to delete a record from the DB the following happens: When Deleting a record: Fatal Error: Can't call method "fetchrow_arrayref" on an undefined value at GT::SQL::File::delete_records line 275. Stack Trace: GT::Base (2704): main::fatal called at...
0
8996
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6799
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.