PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Try It Free
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old September 12th, 2002, 04:07 PM
bmhm bmhm is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 51 bmhm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
File upload not recognized.

I have a simple script which uploads a single file. It works great on another server, but not this one. Here is the script

Code:
<?php

if (is_uploaded_file($_FILES['filename']['tmp_name']))
   {
	$filename = $_FILES['filename']['tmp_name'];
	$realname = $_FILES['filename']['name'];
	copy($_FILES['filename']['tmp_name'], $realname);
   }
   else
   {
      echo "Possible file upload attack: filename".$_FILES['userfile']['name'].".";
   }
?>


It goes directly to the else in this statement. I then tried printing the $_FILES['filename']['tmp_name']; stuff and there is nothing in the there.

Any ideas why it is not recognizing the file.

Also I checked the variables in the phpinfo and the variable from the form is adding on an extra backslash. see below.

C:\stuff\file.cvs

That double \ before file should not be there. COuld this be causing the problem?

Reply With Quote
  #2  
Old September 12th, 2002, 05:33 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: File upload not recognized.

what version of PHP is running on this new server? is_uploaded_file() is available only in versions of PHP 3 after PHP 3.0.16, and in versions of PHP 4 after 4.0.2. extra slashes could definately be causing a problem, yah.. also the "$_FILES" was introduced in PHP 4.1.0 - in earlier versions, use $HTTP_POST_FILES.

Reply With Quote
  #3  
Old September 12th, 2002, 06:01 PM
bmhm bmhm is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 51 bmhm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: File upload not recognized.

I have the version of PHP 4.2.2.

I belive that the double slashed are the main problem. How do I fix that?

Reply With Quote
  #4  
Old September 12th, 2002, 06:38 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: File upload not recognized.

can we see some more code please? the html form and the code which processes it.. gotta know exactly where the slash is being added in order to fix it

Reply With Quote
  #5  
Old September 13th, 2002, 03:04 PM
bmhm bmhm is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 51 bmhm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Here is the html part

Code:
	
<form name="form1" method="post" action="upload.php">
	<table width="500" border="0" align="center" cellpadding="1" cellspacing="0">
		<tr> 
		<td><p align="center"><font color="#336699" size="4" face="Arial, Helvetica, sans-serif"><strong>Upload File</strong></font></p></td>
		</tr>
		<tr>
                <td bgcolor="#336699">
		<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
			<tr> 
			<td width="29%" height="40" align="right" bgcolor="#FFFFFF"><font size="2" face="Arial, Helvetica, sans-serif">File: </font></td>
			<td width="71%" height="40"  bgcolor="#FFFFFF"> &nbsp;&nbsp;&nbsp; <input type="file" name="filename"> </td>
                </tr>
		<tr valign="top">
                <td height="40" colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" name="Submit" value="Upload"></td>
                </tr></table></td></tr></table>

Reply With Quote
  #6  
Old September 13th, 2002, 03:21 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: File upload not recognized.

couple things right off the bat.. i can't see where any slashes are being added but your form tag should include the enctype: <form enctype="multipart/form-data">

you should specify the max size allowed: <input type="hidden" name="MAX_FILE_SIZE" value="1000">

all kinds of additional uploading information can be found here

Reply With Quote
  #7  
Old September 13th, 2002, 04:07 PM
bmhm bmhm is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 51 bmhm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: File upload not recognized.

Thank you the <form enctype="multipart/form-data"> was what was missing. It works beautiful now.

Good Job!

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > File upload not recognized.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway