|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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'] |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > uploading prob |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|