garrensilverwing
New Member
- Messages
- 148
- Reaction score
- 0
- Points
- 0
I am trying to create a section where users will be able to make profiles on the website. This is so people can leave comments and stuff on emails and news articles and people will be able to learn a little about them. Also it will come in handy later when I start adding more and more features. I am having an issue though. I want people to be able to upload pictures to their profile. They would upload the picture, the server would make sure its a picture then email me telling me a picture is uploaded and waiting for approval. I am running into a few issues though.
Anyway, when I try to upload a test picture it tells me that it is not jpeg or gif format, when it is. Thanks for the help in advance!
Here is my code (its not all of the code, just the parts that are necessary):
Anyway, when I try to upload a test picture it tells me that it is not jpeg or gif format, when it is. Thanks for the help in advance!
Here is my code (its not all of the code, just the parts that are necessary):
Code:
<form method="post" action="editprofile.php" enctype="multipart/form-data">
Change Picture<input type="hidden" name="MAX_FILE_SIZE" value="500" /><input type="file" name="file_up" />
<br /></center>
<input name="submit" type="submit" value="submit" /></center>
</form>
$file_upload="true";
$file_up_size=$_FILES['file_up'][size];
echo $_FILES['file_up'][name];
if ($_FILES['file_up'][size]>150000)
{
$msg=$msg."Your uploaded file size is more than 150KB so please reduce the file size and then upload.<BR>";
$file_upload="false";
}
if (!($_FILES['file_up'][type] =="image/jpeg" OR $_FILES['file_up'][type] =="image/gif"))
{
$msg=$msg."Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
$file_upload="false";
}
$file_name=$_FILES['file_up'][name];
$add="images/pending/$file_name"; // the path with the file name where the file will be stored, upload is the directory name.
if($file_upload=="true")
{
if(move_uploaded_file ($_FILES['file_up'][tmp_name], $add))
{}
else
{
echo "Failed to upload file Contact Site admin to fix the problem";
}
}
else
{
echo $msg;
}