General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 15th, 2003, 01:29 AM
Alicia Alicia is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 116 Alicia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 27 m 49 sec
Reputation Power: 6
uploading prob

Hi guys,

can somebody give me an idea what have i done wrong ??? it displayed "Error : Possible file upload error" as my output..

my code:
<head>
<title>
Uploading ....
</title>
</head>

<body>
<h1> Uploading file .. </h1>
<?
if($userfile == "none")
{
echo 'Error : No file uploaded ';
exit;

}

if($usefile_size == 0)
{
echo 'Error : Uploaded file is zero lenght';
exit;
}

if($usefile_type != "image/gif")
{
echo 'Error : Incompatible file detected';
exit;
}

if(!is_uploaded_file($userfile))
{
echo 'Error : Possible file upload error';
exit;
}

$upfile = $userfile_name;

if(!copy($userfile, $upfile))
{
echo 'Error : Could not copy the file';
exit;
}


echo "File uploaded <br><br>";

$fp = fopen($upfile,"r");
$content = fread($fp, filesize ($upfile));
fclose($fp);

$contents = strip_tags($contents);
$fp = fopen($upfile, "w");
fwrite($fp, $contents);
fclose($fp);

echo "preview of uploaded file contents: <br><hr>";
echo $contents;
echo "<br><hr>";
?>
</body>


everything looks okay for me but why i still get this error when i upload gif file.. i have changed to text/plain and upload text file but error still occured (display "Error:Incompatible file detected") My code just doesn't work at all...

is there any website i can go to refer to what i suppose to use when i wanna upload a word doc, excel file and etc .. (i mean like image/jpeg , text/,,,, )

hope you guys may able to help me.

please advise.

Reply With Quote
  #2  
Old December 15th, 2003, 02:45 PM
Mike_r Mike_r is offline
ExoCrew
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 68 Mike_r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
You should use $_FILES global.
Some info:

$_FILES['userfile']['name']
The original name of the file on the client machine.

$_FILES['userfile']['type']
The mime type of the file, if the browser provided this information. An example would be "image/gif".

$_FILES['userfile']['size']
The size, in bytes, of the uploaded file.

$_FILES['userfile']['tmp_name']
The temporary filename of the file in which the uploaded file was stored on the server.

$_FILES['userfile']['error']

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > uploading prob


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 2 hosted by Hostway
Stay green...Green IT