I'm having problems uploading files to my server.
I've created an admin tool to upload images to my site (Orion22.com ) and relate them to a specific story. Sometimes it works and sometimes it doesn't. It does this apparently in an arbitrary fashion. I check for file type before uploading the image. Should I check for file size too?? Has anybody had a similar problem??
Here's the code that processes the upload form should anybody want to give me a hand with this. Thanks!!
if (!is_uploaded_file($HTTP_POST_FILES['file']['tmp_name'])) {
$error = "You did not upload a file!";
unlink($HTTP_POST_FILES['file']['tmp_name']);
} else {
//a file was uploaded
};
if ($HTTP_POST_FILES['file']['type'] != "image/gif" AND $HTTP_POST_FILES['file']['type'] != "image/pjpeg") {
$error = "This file type is not allowed";
unlink($HTTP_POST_FILES['file']['tmp_name']);
// assign error message, remove uploaded file, redisplay form.
} else {
//File has passed all validation, copy it to the final destination and remove the temporary file:
copy($HTTP_POST_FILES['file']['tmp_name'],"../images/noticias/".$HTTP_POST_FILES['file']['name']);
unlink($HTTP_POST_FILES['file']['tmp_name']);
$fichero=$_FILES['file']['name'];
$sql_query="UPDATE links_noticias SET url_image='http://www.orion22.com/images/noticias/$fichero' WHERE id_link=$last_id";
$result = mysql_query($sql_query);
};
Orion22.com