Ive just sorted the hosting out for my new site, and uploaded it throughout the day... sorting the database out and crushing errors with my mighty notepad.
All was going well untill i came to test my image upload facility.
6 hours and 12 phonecalls to www.fasthosts.co.uk technical support.... and i'm ready to seriously hurt the next poor s.o.b who looks at me funny 😉
I have been told ....... "we dont have a tmp directory for php uploads" ........ "I cant help we dont support scripting and its not our fault your codes wrong" and my favorite ... "whats php?"
I'm pretty sure its a configuration error, and i think i need to find the tmp directory that the image is uploaded to before i move it.
Ok, guys i need help;
I've even tried creating my own tmp file..... but that didnt work (not that i thought it would)
heres my script ;
<?php
session_start();
include("../private.inc");
if ( $_SESSION['login'] != "true" )
{
header("location: ../registration.php");
}
else
{
$connection=mysql_connect($host, $user, $passwd)
or die ("Could not connect !");
$db = mysql_select_db($database, $connection)
or die ("Could not connect to Database");
//Process the large size image ****************
$username = $_SESSION['username'];
if (($_FILES['filename']['type']!="image/jpeg") && ($_FILES['filename']['type']!="image/pjpeg") && ($_FILES['filename']['type']!="image/gif")) {
echo "Sorry you must upload only files of the type .jpg .jpeg or .gif, Click <a href='../picturemanager.php'>Here</a> to try again";
} else {
$connection = mysql_connect($host, $user, $passwd) or die ("Could not connect !");
$db = mysql_select_db($database, $connection) or die ("Could not connect to Database");
$query = "SELECT picture1 FROM pictures WHERE user_name='$username'";
$exist = mysql_query($query) or die ("could not Select Picture.");
preg_match('/\.\w{3,4}$/', $_FILES['filename']['name'], $matches);
$new_filename = $_SESSION['username']."1".$matches[0];
$filepath = "member_pics/full_size/".$new_filename;
if (file_exists($filepath)) {
unlink("member_pics/full_size/".$new_filename);
}
$source = "member_pics/full_size/".$new_filename;
move_uploaded_file($_FILES['filename']['name'], $source); // move the file
$query = "UPDATE pictures SET picture1 = '$filepath' WHERE user_name='{$_SESSION['username']}'";
$result = mysql_query($query) or die ("could not add picture.");
}
}
You shuld be able to see what this scripts trying (and failing) to do..... upload the file... move it to the directory i want to keep it in, check the file doesnt allready exist, delete if it does, and insert the path in my database.
Can anyone help me with this, im going mad .... or , has anyone got experiance of this problem with Fasthosts, that can shed some light?
I really appreciate any assistance or advice on this
thanks in advance.