Jump to content

File UPload? What's WRONG?!


sodascape

Recommended Posts

[b]What is wrong with this script?  It keeps spitting out, "Your File Could NOt Be Uplaoded Because:     [/b]

[code] <?php
// IMAGE UPLOAD FUNCTION
function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth)
{
$srcImg = imagecreatefromjpeg("$imageDirectory/$imageName");
$origWidth = imagesx($srcImg);
$origHeight = imagesy($srcImg);

$ratio = $thumbWidth / $origWidth;
$thumbHeight = $origHeight * $ratio;

$thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight);

imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $origWidth, $origHeight);
imagejpeg($thumbImg, "$thumbDirectory/$imageName");
}
// END IMAGE UPLOAD FUNCTION


$done = 'false';

if (isset($_POST['upload'])) {

// IMAGE UPLOAD
if (move_uploaded_file ($_FILES['picture1']['tmp_name'], "picpost/{$_FILES['picture1']['name']}")) {

} else {

echo '<p>Your file could not be uploaded because:</p>';

switch ($_FILES['picture1']['error']) {
case 1:
echo 'Your file is bigger than what the server can hold!';
break;
case 2:
echo 'Your file is too big!';
break;
case 3:
echo 'Only part of the file was uploaded!';
break;
case 4:
echo 'No file was uploaded.';
break;
}
exit();
}// End If Move Uploaded File

$fileName = $_FILES['picture1']['name'];

    if(!get_magic_quotes_gpc()) {
           $fileName = addslashes($fileName);
    } // end get_magic_quotes_gpc


// CALL THE FUNCTION TO CREATE THUMBNAIL
createThumbnail("picpost", "$fileName", "picpost/thumbs", 100);
$done = 'true';

} // END OF THE IMAGE UPLOAD

?>




<form method="post" action="upload.php">
<input type="file" name="picture1" />
<input type="submit" name="upload" />
</form>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.