Reputation: 123
Ok, so i have been using html for quite a while and am learning how to use php functions now. I have a domain and am using a hosting site to host my files, i have a php file that allows users to upload pictures to a specified file but i keep getting error messages. the function works on my server, so i know it is correct, so i believe that this is probably a security issue with the site that i am using to host the file. so i would like to use my server to handle the php and accept the upload. i tried just entering my url of the php file on my server in the #post line but i should have known it would not be that simple. i researched this and it looks like i need to set up a "listening page" php file and a variable that defines the url. since i am very new to this i was hoping someone could help me with specific instructions so that i can see the mechanics of this and understand it better. this is my code:
<form enctype="multipart/form-data" action="upload.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br/>
<input type="submit" value="Upload" />`
once the user submits the file it is handled by the following code
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else {
echo "Sorry, there was a problem uploading your file.";
}
if ($uploaded_size > 10000)
{
echo "Your file is too large.<br>";
$ok=0;
}
if ($uploaded_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}
so how to i get the form to call this function on my server? http://www.server-name/folder/upload.php
Upvotes: 3
Views: 3933
Reputation: 30488
This is caused because your server is not allowing you to upload external images to your server.
Change server's image upload directory permission to 777
.
Upvotes: 1