TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 02-25-2008, 02:33 AM   #1 (permalink)
The Wanderer
 
Join Date: Feb 2008
Posts: 13
Thanks: 3
gillweb is on a distinguished road
Unhappy Host Upgraded - File Upload won't work now

I have had my site working for MANY years until recently my host had upgraded the server to PHP 5. Sicne then I can't get a simple file upload to work? Can anyone look at this code and tell me why it wouldn't work?

The error I am getting is "Sorry. You did not chose an image" which I am assuming means the file string isn't being passed on??? But the weirder thing is I am getting the "Ad uploaded" message also? So it's telling me there is an error but also saying it was uploaded (which it isn't).

PHP Code:
<?php
$adtitle 
$_POST['adtitle'];
$adtype $_POST['adtype'];
$imagetype $_POST['imagetype'];
$adimagefile $_POST['adimagefile'];
$url $_POST['url'];
$groupid $_POST['groupid'];


   
$error false;
   
$errormessage "";

   if (
strlen($adtitle) < 1) {
      
$error true;
      
$errormessage .= "<li><b>Sorry.  You did not enter an ad title.</b><br>\n";
   }
   if (
$adtype == 'A'){
      if (
strlen($code) < 1) {
         
$error true;
         
$errormessage .= "<li><b>Sorry.  You did not enter an affiliate code.</b><br>\n";
      }

   }

   if (
$adtype == 'O'){
      if (
strlen($adimagefile) < 1) {
         
$error true;
// HERE"S MY ERROR!!!!!
         
$errormessage .= "<li><b>Sorry.  You did not chose an image</b><br>\n";
      }
      if (
$imagetype == "") {
         
$error true;
         
$errormessage .= "<li><b>Sorry.  You did not chose an image type.</b><br>\n";
      }
      if (
strlen($url) < 1) {
         
$error true;
         
$errormessage .= "<li><b>Sorry.  You did enter a URL</b><br>\n";
      }

   }

?>

<h2>Save new ad</h2>
<p>

    <?php
$adid 
nextid("ads""adid");

        if(
$adtype == 'O'){
// HERE's MY UPLOAD
            
$newfilename "../ads/$adid.$imagetype";
            
$picfile $HTTP_POST_FILES['userfile']['tmp_name'];
            
copy($adimagefile$newfilename);
            
printf("Ad uploaded<br>");
        }

        if (
$error) {
           
printf("<font color=red>There was a problem creating the ad!</font><br><br>Please click on back in your browser to fix the problems listed below.<br>");
           
printf($errormessage);
        } else {

        if (
$adtype == 'A'){
           
$sql "insert into ads (adid, code, impressions, clicks, groupid, type, name) values ($adid, '$code', 1, 1, $groupid, '$adtype', '$adtitle')";
        }

        if (
$adtype == 'O'){
           
$newurl "http://";
           
$newurl .= $url;
           
$sql "insert into ads (adid, image, url, impressions, clicks, groupid, type, name) values ($adid, '$imagetype', '$newurl', 1, 1, $groupid, '$adtype', '$adtitle')";
        }

           
$result mysql_query($sql ,$db);

           
printf("<p>The ad has been added to the group.</p>");
           
printf("<p><a href=editadgroup.php?groupid=$groupid>Back to ad group</a></p>");

        }
    
?>

</p>
gillweb is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 06:47 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design