siri Posted March 1, 2007 Share Posted March 1, 2007 Hi,I tried the follwing code for uploading images but I am getting follwing error Warning: move_uploaded_file(/67ff50fd1e1519ec658b190ef4fd280a.jpg): failed to open stream: Read-only file system in on line 14Warning: move_uploaded_file(): Unable to move '/tmp/phpSXlIXr' to '/67ff50fd1e1519ec658b190ef4fd280a.jpg' in on line 14Here is the code:************************************<html><?php $path=$_SERVER[DOCUMENT_ROOT];if(isset($_post['submit'])){ $title=$_POST['title']; $thumb=$_POST['thumb']; $id=$_POST['alb']; $name= $_FILES['flimage']['name']; $ext=strchr($name,"."); $newname=md5(rand()*time()).$ext; $file=$path.$newname; $result = move_uploaded_file($_FILES['flimage']['tmp_name'], $file);if(!result){die('couldnot upload');}else{ echo 'Success';}if (!get_magic_quotes_gpc()) { $title = addslashes($title); $thumb = addslashes($thumb); $file=addslashes($file); } $conn=mysql_connect("db5.awardspace.com","pa","********");mysql_select_db("pa",$conn);$sql="insert into images(title,fname,alb_id,thumbnail) values('$title','$file',$id,'$thumb')";$result=mysql_query($sql);if(!result)die('Error');mysql_close($conn);}?><form action="" method=post enctype="multipart/form-data"><table border=1><tr><td>Title: </td><td><input type=text name=title></td></tr><tr><td>Thumbnail: </td><td><input type=text name=thumb></td></tr><tr><td>Album Id: </td><td><input type=text name=alb></td></tr><tr><td>File Name: </td><td><input type=file name=flimage></td></tr><tr><td><input type=submit name=submit value="Submit"></tr></table></form></body></html> Link to comment Share on other sites More sharing options...
justsomeguy Posted March 1, 2007 Share Posted March 1, 2007 The error message says read-only file system. You are trying to move the file to the root of the drive, you can't do that. You are not using the document root right, you need to use quotes. Change these two lines:$path=$_SERVER[DOCUMENT_ROOT];if(isset($_post['submit']))to this:$path=$_SERVER['DOCUMENT_ROOT'];if(isset($_POST['submit'])) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now