$name   = $_POST['name'];
$image   =  $_FILES['image'];
$location   = $_POST['location'];
$category   = $_POST['category'];
$username   = $_POST['username'];
//$imageData =addslashes (file_get_contents($_FILES['image']['tmp_name']));
$imageData =addslashes (file_get_contents("http://zbatny.info/HOOT/amsek/prob/5.jpg"));
$image =$_FILES['image']['name']; 

echo('You cannot upload to the specified directory, please CHMOD it to 777.');


 //Tells you if its all ok 
 echo "The file ". basename( $_FILES['image']['name']). " has been uploaded, and your information has been added to the directory"; 
 else { 

 //Gives and error if its not 
 echo "Sorry, there was a problem uploading your file."; 
//$insert = "INSERT INTO problems(Name,Description,Image, Location, Category, Username, Vote, Spam) VALUES ('" . $name . "','sherif sobhy','$image','0','0','" . $username . "','0','0')";

$query  = mysql_query($insert);  
    if ($query) 
        echo "Thank You";  
        echo "Insertion failed";  

Inline Code Example Here
i tried many paths but i can't insert so please anyone help me thanks in advanced but here to make sure that my php is right i upload i inserted it in my server and i give it the path

Recommended Answers

All 7 Replies

Member Avatar

What's this got to do with javascript?

$insert = "INSERT INTO problems(Name,Description,Image, Location, Category, Username, Vote, Spam) VALUES ('$name','sherif sobhy','$image','0','0','$username','0','0')";

Should work.

the insertion process works normally but i commented it because now my problem is that i can't upload into my server i don't know why ????

Member Avatar
$image =$_FILES['image']['name']; 

is wrong if you are going to use it as the source file in move_uploaded_file. use:

$image =$_FILES['image']['tmp_name']; 

done but now it show me this error
Warning: move_uploaded_file(/home/amrfahmy/domains/zbatny.info/public_html/images/940_10151528660414606_2076416029_n.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/amrfahmy/domains/zbatny.info/public_html/HOOT/amsek/prob/insert_prob.php on line 29

now its working i changed the permission to 777

Member Avatar

OK, mark as solved.

When i was doing i too face the same problem.on seeing this thread i just tried and got solved..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.