|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
Problems: fle uploading vs temp path.
Hi,originally this script
runs well on my local machine Apache+php+Mysql. But once I uploaded it to my free website,it became useless. When I executed the following script, I got the following errors: Warning: fopen("", "r") - No such file or directory in C:webserverwebservermanagergigiclubuploadtest.php on lin e 7 Warning: fread(): supplied argument is not a valid File-Handle resource in C:webserverwebservermanagergigiclubuploadtest.php on lin e 7 My script ---------------------------uploadtest.php------------------- --------------- <?php require('config.php'); ?> <? //uploadtest.php global $PHP_SELF,$yourname,$image; if($submit){ $img = addslashes(fread(fopen($image, "r"), filesize($image))); $query="insert into mytable values('$yourname','$img')"; $result=mysql_db_query("mydatabase",$query); if($result) print("Thank you $yourname,your image file is successfully uploaded"); else print("Couldn't upload your image file."); } else { print(" <form enctype=multipart/form-data action=$PHP_SELF method=post> <table><tr><td>Your name<input name=yourname></td></tr> <tr><td>Your image file<input type=file name=image><input type=submit name=submit value=submit></td></tr></table></form>"); } ?> My config.php contains all the info needed connecting to MySQL database(host,username,password..) And my sql script is as followed: create table mytable(yourname varchar(40),image blob); My problem is that when the fopen / fread command looks for the tmp folder - it can`t find it. I have even tried adding $image = str_replace("\\","\",$image); (but still not working) I think there should be some problems with this line: $img = addslashes(fread(fopen($image, "r"), filesize($image))); Please help. Thank you. David Foo janhouse00@hotpop.com |
|
#2
|
||||
|
||||
|
RE: Problems: fle uploading vs temp path.
Quote:
as you see the variable $image can not be found and used on your "fopen" function to handle the file. If fopen function could get the variable, it should got some errors like follows: Quote:
|
|
#3
|
|||
|
|||
|
RE: Problems: fle uploading vs temp path.
is the folder you are trying to grab info out of chmod'd correctly?
That is a typical error that i received a couple of times, when it was not 755 or 777. It all depends on what server you are running on to, so normally the (r) or (w) on some systems are basically useless...to combat it, you can try this command chmod("thisfile.txt",777) of course, FTPing to the file, and using the CHMOD mode works much better. (something like that anyways |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Problems: fle uploading vs temp path. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|