---------------------------------------------------------------
Warning: fread(): supplied argument is not a valid stream resource in D:\Public_Site\multifileupload\welcome_addfiles.ph p on line 28
------------------------------------------------------------
i am trying many ways by giving diff arguments in fread()
---------------------------------------------------
suggest me ,
wat error ,how to rectify it.
THIS CODE IS BASICALLY TO UPLOAD A FILE TO DB AND IMG TO UPLOAD FOLDER.
Expand|Select|Wrap|Line Numbers
- <?php
- $uploadDir = 'D:/localhost/multifileupload/upload/';
- //'mutlifileupload' if folder name where v save files in.
- //'upload'(to save images) is folder in 'multifileupload'.
- if (($_FILES["file"]["type"] == "image/gif")
- || ($_FILES["file"]["type"] == "image/jpeg")
- || ($_FILES["file"]["type"] == "image/jpeg")
- && ($_FILES["file"]["size"] < 20000))
- {
- if ($_FILES["file"]["error"] > 0){
- echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
- }
- else if (file_exists("upload/" . $_FILES["file"]["name"]))
- {echo "Entered File:-----".$_FILES["file"]["name"] . " :-----Already exists. <BR/>";}
- else
- {
- $filePath = $uploadDir . $fileName;
- //----------this is to store in db mysql-----------
- $lnk=mysql_connect('localhost','root','etg') or die(mysql_error());
- mysql_select_db('registrationformdb',$lnk);
- $sql="select * FROM registrationformdb.image ";
- //'registrationformdb' is db name,'image' is table name
- $photo = addslashes(fread(fopen($_FILES['upload']['tmp_name'],"r"), $_FILES['file']['size']));
- $query = sprintf("INSERT INTO image(FileName) VALUES ('".$_FILES["file"]["name"]."')");
- if (mysql_query($query))
- {
- $messages[] = "Your files is successfully store in database";
- }
- else {$messages[]= mysql_error();}
- //----------end this is to store in db mysql----------------
- echo "<h3>you are succesfully uploaded the file</h3><br/>";
- echo "Upload: " . $_FILES["file"]["name"] . "<br />";
- echo "Type: " . $_FILES["file"]["type"] . "<br />";
- echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
- echo "Temp file: " . $_FILES["upload"]["tmp_name"] . "<br />";
- //here v move the upload files into 'upload' folder
- move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
- echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
- }
- }
- else{echo "Invalid file";}
- ?>