Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Apr 2003
    Posts
    56
    Member #
    1043
    Hi, I am having some problems trying to make an upload script..heres my script:

    <?php if ($HTTP_POST_VARS['action']) { ?>
    <HTML>
    <HEAD>
    <TITLE>File Upload Results</TITLE>
    </HEAD>
    <BODY BGCOLOR="WHITE" TEXT="BLACK">
    <P><FONT FACE="Arial, Helvetica, sans-serif"><FONT SIZE="+1">File Upload
    Results</FONT><BR><BR>
    <?php

    $uploadpath = '/www/www/customdsg/explore/admin/files/';
    $source = $HTTP_POST_FILES['file1']['tmp_name'];
    $dest = '';

    if ( ($source != 'none') && ($source != '' )) {

    $imagesize = getimagesize($source);

    switch ( $imagesize[2] ) {

    case 0:

    echo '<BR> Image is unknown <BR>';
    break;

    case 1:
    echo '<BR> Image is a GIF <BR>';
    $dest = $uploadpath.uniqid('img').'.gif';
    break;

    case 2:
    echo '<BR> Image is a JPG <BR>';
    $dest = $uploadpath.uniqid('img').'.jpg';
    break;

    case 3:
    echo '<BR> Image is a PNG <BR>';
    $dest = $uploadpath.uniqid('img').'.png';
    break;

    }

    if ( $dest != '' ) {

    if ( move_uploaded_file( $source, $dest ) ) {

    echo 'File successfully stored.<BR>';

    } else {

    echo 'File could not be stored.<BR>';

    }

    }

    } else {

    echo 'File not supplied, or file too big.<BR>';

    }

    ?>
    </FONT></P>
    </BODY>
    </HTML>
    <?php } else { ?>
    <HTML>
    <HEAD>
    <TITLE>File Upload</TITLE>
    </HEAD>
    <BODY BGCOLOR="WHITE" TEXT="BLACK">
    <P><FONT FACE="Arial, Helvetica, sans-serif"><FONT SIZE="+1">File
    Upload</FONT><BR><BR>

    If your browser is upload-enabled, you will see &quot;Browse&quot; (Netscape,
    Internet Explorer), or &quot;...&quot; (Opera) buttons below. Use them to
    select files to upload, then click the &quot;Upload&quot; button. After the
    files have been uploaded, you will see a results screen.<BR>

    <FORM METHOD="POST" ENCTYPE="multipart/form-data"
    ACTION="<?php echo $PHP_SELF;?>">

    <INPUT TYPE="HIDDEN" NAME="MAX_FILE_SIZE" VALUE="800000">
    <INPUT TYPE="HIDDEN" NAME="action" VALUE="1">
    File 1: <INPUT TYPE="FILE" NAME="file1" SIZE="30"><BR><BR>
    <INPUT TYPE="SUBMIT" VALUE="Upload">
    </FORM>
    </FONT></P>
    </BODY>
    </HTML>
    <?php } ?>


    and my error is

    Warning: move_uploaded_file(/www/www/customdsg/explore/admin/files/img3f2fc1060f820.gif): failed to open stream: No such file or directory in /home/tnrstudi/www/www/customdsg/explore/dl/admin/upload.php on line 45

    Warning: move_uploaded_file(): Unable to move '/tmp/phpbi1eNi' to '/www/www/customdsg/explore/admin/files/img3f2fc1060f820.gif' in /home/tnrstudi/www/www/customdsg/explore/dl/admin/upload.php on line 45
    File could not be stored.

    Any Ideas why this is happening
    http://www.tnrstudios.com/ - Designing the web one site at a time

  2.  

  3. #2
    Member
    Join Date
    Apr 2003
    Posts
    56
    Member #
    1043
    any ideas..?
    http://www.tnrstudios.com/ - Designing the web one site at a time

  4. #3
    Senior Member james's Avatar
    Join Date
    May 2003
    Location
    Melbourne, AUSTRALIA
    Posts
    364
    Member #
    1352
    the var $uploadpath is set to '/www/www/customdsg/explore/admin/files/', but it says the path to the script is '/home/tnrstudi/www/www/customdsg/explore/dl/admin/', so change it to either:

    '/home/tnrstudi/www/www/customdsg/explore/dl/admin/files/' (not portable)

    or

    './files/' (probably better).
    James H
    Home Page · Mars Page · www.fihsf1.net (formerly www·fihs·net)

  5. #4
    Member
    Join Date
    Apr 2003
    Posts
    56
    Member #
    1043
    k I tried that but now I get this error:

    Warning: move_uploaded_file(/home/tnrstudi/www/www/customdsg/explore/dl/admin/files/img3f31268f17c58.gif): failed to open stream: Permission denied in /home/tnrstudi/www/www/customdsg/explore/dl/admin/upload.php on line 45

    Warning: move_uploaded_file(): Unable to move '/tmp/phpMyPiIx' to '/home/tnrstudi/www/www/customdsg/explore/dl/admin/files/img3f31268f17c58.gif' in /home/tnrstudi/www/www/customdsg/explore/dl/admin/upload.php on line 45
    File could not be stored.
    http://www.tnrstudios.com/ - Designing the web one site at a time

  6. #5
    Senior Member james's Avatar
    Join Date
    May 2003
    Location
    Melbourne, AUSTRALIA
    Posts
    364
    Member #
    1352
    That's probably server configuration... if you've tried both alternatives I gave, talk to your host, and ask to allow php to write files in that directory. Maybe before that you should do a test and try to write a file to that directory... and make sure ./files/ exists!
    James H
    Home Page · Mars Page · www.fihsf1.net (formerly www·fihs·net)


Remove Ads

Posting Permissions

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

Search tags for this page

tnrstudi

Click on a term to search for related topics.
All times are GMT -6. The time now is 09:33 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com