Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-07-2005, 05:22 AM upload image script
knowj's Avatar
Novice Talker

Posts: 10
Trades: 0
this script compiles and seems to look fine but im no great scripter. when i try to upload an image it runs the script but it dosnt upload the image. iv set the file im uploading to as 777 whats wrong in this script it worked fine befor i added the image name form.


PHP Code:
<?
//set these variables-----------------------------------------------------------------
$domain "www.sitename.com/Cruise";      //your domainname
$path "../Cruise/mGallery/home/";   //path to your targetfolder
$path_after_domain "mGallery/home/";   //path to your targetfolder for use in url
$max_size 100000;          //maximum filesize
//------------------------------------------------------------------------------------
?>


          <span class="text_mainhead">Image Upload</span> <br>
         <FORM ACTION="gallery_update.php" METHOD="POST" ENCTYPE="multipart/form-data" class="maintext">
           <table width="100%"  border="0" cellpadding="5">
             <tr>
               <td class="text_main">Image Name: </td>
               <td><input name="namefile" type="text" class="text_main" size="40">
                 <span class="text_main">(dont include .jpg)</span></td>
             </tr>
             <tr>
               <td><span class="text_main">IMAGE (jpg)</span></td>
               <td><input name="userfile" type="file" class="text_main" size="40">
                 <input name="submit" type="submit" class="text_main" onClick="MM_validateForm('namefile','','R');return document.MM_returnValue" value="Upload"></td>
             </tr>
           </table>
           </FORM>

<br>
<?

if (!isset($HTTP_POST_FILES['userfile'])) exit;
if (!isset(
$HTTP_POST_FILES['namefile'])) exit;

if (
is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {

if (
$HTTP_POST_FILES['userfile']['size']>$max_size) {
        echo 
"<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">File is too big !</font><br>\n"; exit; }
if ((
$HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg")) {

        if (
file_exists($path $HTTP_POST_FILES['userfile']['name'])) {
                echo 
"<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">There already exists a file with this name, please rename your file and try again</font><br>\n"; exit; }

        
$res copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .$HTTP_POST_FILES['namefile']. ".jpg");

        if (!
$res) { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">Didn't work, please try again</font><br>\n"; exit; } else {
        
?>
<br>  <?
 
}
echo 
"<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\"><hr>";
echo 
"Name: ".$HTTP_POST_FILES['userfile']['name']."<br>\n";
echo 
"Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>\n";
echo 
"Type: ".$HTTP_POST_FILES['userfile']['type']."<br>\n";
echo 
"</font>";
echo 
"<br><br><img src=\"http://" $domain "/" $path_after_domain $_SESSION['MM_Username'] . ".jpg\">";
} else { echo 
"<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">File must be a jpg !!!</font><br>\n"; exit; }

}

?>
knowj is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to upload image script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.07770 seconds with 12 queries