Results 1 to 6 of 6

Thread: File Upload

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    File Upload

    Ok i'm missing somthing here, i've done file uplaod a million times but i cant get this one working.....

    my upload script is below.

    PHP Code:
    <?php
    $uploaddir 
    "http://lindowltc.org.uk/news/"

    if(
    is_uploaded_file($_FILES['file']['tmp_name']))
    {
    move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);
    }

    $path "http://'site'.org.uk/news/" $_FILES['file']['name'];
    $msg "Image Uploaded";

    $host="localhost";
    $user="a";
    $password="b";
    $database="c";

    $connection mysql_connect($host,$user,$password);
    $db mysql_select_db($database,$connection);

    $query =("REPLACE INTO tblNews(id,news) VALUES (1,'$path')");

    header('Location: http://'site'/Admin/news/upload.php?path='.$path."&msg=".$msg);
    ?>
    I'm trying to store the path the file is uploaded to (So and replace the existing path in the DB)

    PHP Code:
    <form enctype="multipart/form-data" action="doUpload.php" method="post">
    <
    input type="hidden" name="MAX_FILE_SIZE" value="500000">
    <
    strong>Upload An Image</strong> -<input type="file" name="file" size="60">
    <
    input type="submit" name="upload" value ="Upload News">
    </
    form
    That the actual upload form,

    Am i missing somthing simple here?

    the errors are,

    Warning: move_uploaded_file(http://path/news//50.jpg[/url]): failed to open stream: HTTP wrapper does not support writeable connections. in /home/lindowltcuk/public_html/Admin/letter/doUpload.php on line 6

    Warning: move_uploaded_file(): Unable to move '/tmp/phpnRLz5L' to 'http://path/news//50.jpg' in /home/path/public_html/Admin/letter/doUpload.php on line 6
    http://path/news/50.jpg
    Warning: Cannot modify header information - headers already sent by (output started at /home/path/public_html/Admin/letter/doUpload.php:6) in /home/path/public_html/Admin/letter/doUpload.php on line 23
    Last edited by Pino; May 14th, 2005 at 09:50 AM.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: File Upload

    You can only copy, move or write to a file on the local file system. The move location is a url and is not writable.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3
    New Member
    Join Date
    Feb 2005
    Posts
    11

    Re: File Upload

    I got that error today, I cant remember if its exactly the same, but how I went about fixing it was, I use smartFTP (www.smartftp.com), so I went to the folder it was sending the data to pressed f7 on it and changed its permission from 755 to 777.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: File Upload

    Thanks, i've allready set the permissions though i think it what visual ad said. I'll try it as soon as i get some time

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: File Upload

    Ok hit a small problem,

    the directory the uplaod is in is,

    home/admin/letter/upload.php

    this directory is .htaccess protected. now then how do i upload to a directory which is 'further back'

    ie - home/letter/

    what would is et the $uploaddir = ""; to?

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: File Upload

    You should use an absolute file path which beings with a solidus (/) "/home/letter/upload"
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width