Well, I am trying to make a script that will allow a user to upload a picture and then it will resize it to the appropriate size if the image being uploaded is not the specified size. Here is the script I am using:
PHP Code:
<?php

########## If Add Was Hit ##########
if ($_POST['add']) {
    
$user mysql_real_escape_string($_POST['user']);
    
$title mysql_real_escape_string($_POST['title']);
    
$description mysql_real_escape_string($_POST['description']);
    
$preview mysql_real_escape_string($_POST['preview']);
    
$date date("n/j/y");
    
    
// File Paths
    
$title1 strtolower($title); $title1 str_replace(' ''_'$title1);
    
$name strtolower($_FILES['file']['name']); $name str_replace(' ''_'$name);
    
$name1 strtolower($_FILES['preview']['name']); $name str_replace(' ''_'$name1);
        
$motages $montagePath.'/'.$title1.$name;
        
$preview $montagePrePath.'/'.$title1.$name1;
    
//
    
    // Check Data
    
$check mysql_query("SELECT * FROM `montage` WHERE title = '$title'") or die ("Error Checking Title! \n<br />\n" .mysql_error());
    
$chk mysql_num_rows($check);
    
//
    
    // Check Fields
    
if (!$user || !$title || !$description) { 
        echo(
'<meta http-equiv="refresh" content="2;URL='.$_SERVER['PHP_SELF'].'" /> <div class="error">Please fill in all fields.</div>');
    }
    
//
    
    // If Title In Use
    
else if ($chk >= 1) { echo('<meta http-equiv="refresh" content="2;URL='.$_SERVER['PHP_SELF'].'" /> <div class="error">Title already in use.</div>'); }
    
//
    
    // If Error Moving Files
    
else if ( !move_uploaded_file($_FILES['file']['tmp_name'], $montages) ) { echo('<div class="error">Error uploading file!</div>'); }
    else if ( !
move_uploaded_file($_FILES['preview']['tmp_name'], $preview) ) { echo('<div class="error">Error uploading preview!</div>'); }
    
//
    
    // If Everything Checks Out
    
else {
        
$insert mysql_query("INSERT INTO `montage` (id, user, title, description, preveiw, url, date) VALUES ('', '$user', '$title', '$description', '$preview', '$montages', '$date')") or die ("Error Adding Montage! \n<br />\n" .mysql_error());
    }
    
//
}

########## If Add Not Hit ##########
if (!$_POST['add']) { ?>

    <div class="message">Adding New Montage</div> <br /><br />
    
        <!-- Add Montage Form -->
                <form method="post" action="<?php echo $_SERVER['PHP_SELF'?>" name="add_montage" enctype="multipart/form-data">
                    <table width="250" align="center">
                        <tr>
                            <td>Username:</td>
                            <td><input type="text" name="user" /></td>
                        </tr>
                        <tr>
                            <td>Title:</td>
                            <td><input type="text" name="title" /></td>
                        </tr>
                        <tr>
                            <td colspan="2">Description:</td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <textarea name="description" id="textarea"></textarea>
                                <script language="JavaScript">
                                    generate_wysiwyg('textarea');
                                </script> 
                            </td>
                        </tr>
                        <tr>
                            <td>Preview (100x100):</td>
                            <td><input type="file" name="preview" /></td>
                        </tr>
                        <tr>
                            <td>URL:</td>
                            <td><input type="file" name="url" /></td>
                        </tr>
                        <tr>
                            <td></td>
                            <td><input type="submit" name="add" value="Add" /></td>
                        </tr>
                    </table>
                </form>
        <!-- /Add Montage Form -->
        
<? }

?>
I get the "error uploading preview" error. I am new to resizing images so my code could be completely wrong. Anything noticeably messed up? Thanks