www.webdeveloper.com
Results 1 to 2 of 2

Thread: file upload help

  1. #1
    Join Date
    Jul 2011
    Posts
    8

    file upload help

    Im having trouble uploading the picture to the folder. The pathway is correct and all the information of the form is sent correctly to the db, just no picture is actually getting uploaded. Im just lost.

    /*imgsubmit.tpl*/
    <form enctype="multipart/form-data"action="admin_site_approval.php" method="post">
    <input type="hidden" name="MAX_FILE_SIZE" value="204800">
    <input type="file" name="fupload" id="fupload" accept="image/jpg,image/gif" />
    <input type="text" name="filename">

    /*imgsubmit.php*/
    if(!empty($fupload)) {
    foreach($HTTP_POST_FILES as $file_name => $file_array) {
    if (is_uploaded_file($file_array['tmp_name'])) {
    $imginfo = getimagesize($file_array['tmp_name']);
    if (in_array($imginfo[2], array(1, 2, 3))) {
    if ($imginfo[2] == 1)
    $upimage = imagecreatefromgif($file_array['tmp_name']);
    elseif ($imginfo[2] == 2)
    $upimage = imagecreatefromjpeg($file_array['tmp_name']);
    else
    $upimage = imagecreatefrompng($file_array['tmp_name']);

    $newx = 50;
    $newy = 70;

    $newimg = imagecreateTrueColor($newx, $newy);
    imagecopyresized($newimg, $upimage, 0, 0, 0, 0, $newx, $newy, imagesx($upimage), imagesy($upimage));
    if(!empty($_POST['filename'])) {
    if(imagejpeg($upimage, '/home/rofl/public_html/uploaded/'.trim($_POST['filename']).'.jpg')) {
    echo "JPG File uploaded successfully<br>";
    }else{
    echo "ERROR! JPG File not uploaded<br>";
    }
    if(imagegif($newimg, '/home/rofl/public_html/uploaded/'.trim($_POST['filename']).'.gif')) {
    echo "Thumbnail (".$_POST['filename'].") uploaded successfully<br>";
    }else{
    echo "ERROR! Thumbnail (".$_POST['filename'].") not uploaded<br>";
    }
    }else{
    $message .= 'Image not saved due to lack of image name<br />';
    }
    }
    }
    }
    }

  2. #2
    Join Date
    Apr 2013
    Posts
    56
    Do you get any errors when you upload files? Have you checked your log files, for any indication of what might be a problem?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles