473,386 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Warning: fread(): supplied argument is not a valid stream resource

For the below code i am getting an error like :
---------------------------------------------------------------
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
  1. <?php
  2.  
  3. $uploadDir = 'D:/localhost/multifileupload/upload/';
  4. //'mutlifileupload' if folder name where v save files in.
  5. //'upload'(to save images) is folder in 'multifileupload'.
  6.  
  7. if (($_FILES["file"]["type"] == "image/gif")
  8. || ($_FILES["file"]["type"] == "image/jpeg")
  9. || ($_FILES["file"]["type"] == "image/jpeg")
  10. && ($_FILES["file"]["size"] < 20000))
  11.   {
  12.   if ($_FILES["file"]["error"] > 0){
  13.     echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
  14.     }
  15.     else  if (file_exists("upload/" . $_FILES["file"]["name"]))
  16.              {echo "Entered File:-----".$_FILES["file"]["name"] . " :-----Already exists. <BR/>";}
  17.           else
  18.             {
  19.             $filePath = $uploadDir . $fileName;
  20.  
  21.         //----------this is to store in db mysql-----------            
  22.           $lnk=mysql_connect('localhost','root','etg') or die(mysql_error());
  23.           mysql_select_db('registrationformdb',$lnk);
  24.           $sql="select * FROM registrationformdb.image ";
  25.             //'registrationformdb' is db name,'image' is table name
  26.           $photo = addslashes(fread(fopen($_FILES['upload']['tmp_name'],"r"), $_FILES['file']['size']));
  27.           $query = sprintf("INSERT INTO image(FileName) VALUES ('".$_FILES["file"]["name"]."')");    
  28.  
  29.           if (mysql_query($query)) 
  30.               {
  31.              $messages[] = "Your files is successfully store in database";
  32.              } 
  33.             else {$messages[]= mysql_error();}
  34.         //----------end this is to store  in  db mysql----------------
  35. echo "<h3>you are succesfully uploaded the file</h3><br/>";        
  36. echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  37. echo "Type: " . $_FILES["file"]["type"] . "<br />";
  38. echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";        
  39. echo "Temp file: " . $_FILES["upload"]["tmp_name"] . "<br />";    
  40.  
  41. //here v move the upload files into 'upload' folder
  42. move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
  43. echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
  44. }
  45. }
  46. else{echo "Invalid file";}
  47. ?>
Sep 20 '07 #1
2 10261
code green
1,726 Expert 1GB
[PHP]$photo = addslashes(fread(fopen($_FILES['upload']['tmp_name'],"r"), $_FILES['file']['size']));[/PHP] Should 'upload' be 'file'?
Sep 20 '07 #2
pbmods
5,821 Expert 4TB
Heya, Yogitha. Welcome to TSDN!

Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).

Please use CODE tags when posting source code:

[CODE=php]
PHP code goes here.
[/CODE]
Sep 20 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Pratchaya | last post by:
Hi Everyone ============================================================== About PHP::: Error/Problem PHP Warning: mysql_fetch_array():...
2
by: 00webman | last post by:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/html/scripts/07/view_users.php on line 15 Can anyone spot my error?!? Thanks. <?php # Script 7.6 -...
3
by: petemaxi | last post by:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\tockholes\includes\menu.inc.php on line 9 <div class="left"> <div class="menu">...
4
by: Ryanlawrence1 | last post by:
Heya, I get these 2 errors: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 20 You have not entered all the...
2
by: techjohnny | last post by:
Error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/jplane/certcent/phpweb/quiz/index.php on line 20 Warning: mysql_num_rows(): supplied argument is...
3
by: varun aggarwal | last post by:
Hi i am doing a project in php that has to read the particular text from the file . I am still unable to get the source of error. what all it mentions is this message. "supplied argument is not...
1
by: lsmamadele | last post by:
I am getting the following error messages in my search: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on...
11
by: Breana | last post by:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/breana/public_html/category.php on line 88 ------------------------------------------- It does this...
7
bobzillaforever
by: bobzillaforever | last post by:
I'm unable to get the file(s) in question to read with file_exists(), fread(), or probably any similar function. I've tried it with .txt, .flv, .pdf, .mov, .mp3, and .wmv. I've tried removing the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.