SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    file uploading error

    hi, getting an error with this code:
    PHP Code:

        $time
    =time();
        
    $filename1 $headline."_1_".$time.substr($file1strrpos($file1"."));
        
    $filename2 $headline."_2_".$time.substr($file2strrpos($file2"."));
        
    // Copy the file
        
    echo"$filename1";
        if (
    $file1 '')
        {
            if (
    copy($file1$filename1)) 
            {  
                
    // whatever
            
    }
        }
        
        if (
    $file2 '')
        {    
            if (
    copy($file2$filename2)) 
            {  
            
    // whatever    
            
    }
        } 
    the error says:

    Warning: Unable to open 'C:\WINDOWS\Desktop\andysambrielaz2.jpg' for reading: No such file or directory in /www/dotcommediainc/newssubmit/form.php3 on line 11

    Warning: Unable to open 'C:\WINDOWS\Desktop\MacKay Pics\andysambrielaz.jpg' for reading: No such file or directory in /www/dotcommediainc/newssubmit/form.php3 on line 19

    any ideas on whats going on?

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep your file is never getting uploaded Make sure your form has the necesarry parts to allow for uploads, namely the enctype and the method.

    Proper form tag

    Code:
    <form action="" method="POST" enctype="multipart/form-data">
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    looks ok...
    here is my form

    PHP Code:
    <form onsubmit="return FrontPage_Form1_Validator(this)"  action="form.php3" enctype='multipart/form-data' >
    <
    div align="center">
      <
    center>
      <
    table border="0" width="361">
        <
    tr>
          <
    td width="351" colspan="2">
            <
    p align="center"><font face="Arial" size="2">Submit News Story</font></td>
        </
    tr>
        <
    tr>
          <
    td width="119"><font face="Arial" size="2">Headline</font></td>
          <
    td width="226"><!--webbot bot="Validation" B-Value-Required="TRUE"
            
    I-Minimum-Length="2" --><input type="text" name="headline" size="31"></td>
        </
    tr>
        <
    tr>
          <
    td width="119"><font face="Arial" size="2">Location</font></td>
          <
    td width="226"><!--webbot bot="Validation" B-Value-Required="TRUE"
            
    I-Minimum-Length="2" --><input type="text" name="place" size="31"></td>
        </
    tr>
        <
    tr>
          <
    td width="119"><font face="Arial" size="2">Source</font></td>
          <
    td width="226"><input type="text" name="source" size="31"></td>
        </
    tr>
        <
    tr>
          <
    td width="119"><font face="Arial" size="2">Story</font></td>
          <
    td width="226"><!--webbot bot="Validation" B-Value-Required="TRUE"
            
    I-Minimum-Length="12" --><textarea rows="8" name="story" cols="26"></textarea></td>
        </
    tr>
        <
    tr>
          <
    td width="119"><font face="Arial" size="2">Contact Name</font></td>
          <
    td width="226"><!--webbot bot="Validation" B-Value-Required="TRUE"
            
    I-Minimum-Length="2" --><input type="text" name="contact_name" size="31"></td>
        </
    tr>
        <
    tr>
          <
    td width="119"><font face="Arial" size="2">Contact #</font></td>
          
    <td width="226"><!--webbot bot="Validation" B-Value-Required="TRUE"
            
    I-Minimum-Length="6" --><input type="text" name="contact_number" size="31"></td>
        </
    tr>
        <
    tr>
          <
    td width="119"><font face="Arial" size="2">Contact E-Mail</font></td>
          <
    td width="226"><!--webbot bot="Validation" B-Value-Required="TRUE"
            
    I-Minimum-Length="5" --><input type="text" name="contact_email" size="31"></td>
        </
    tr>
        <
    tr>
          <
    td width="119"><font face="Arial" size="2">File 1</font></td>
          <
    td width="226"><input type="file" name="file1"></td>
        </
    tr>
        <
    tr>
          <
    td width="119"><font face="Arial" size="2">File 2</font></td>
          <
    td width="226"><input type="file" name="file2"></td>
        </
    tr>
        <
    tr>
          <
    td width="345" colspan="2">
            <
    p align="center"><input type="submit" value="Submit" name="B1"></td>
        </
    tr>
      </
    table>
      </
    center>
    </
    div>
    </
    form

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess you missed the METHOD="POST" part in my post above. As you can't send files through GET which is the default if the METHOD attribute is omitted.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AH! forgot all about method
    thanx

  6. #6
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually, its still not working, im getting

    Warning: Unable to create 'headline_1_1003532582/tmp/phpdgI7Td': No such file or directory in /www/dotcommediainc/newssubmit/form.php3 on line 11


    and i have the post thing on there

  7. #7
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am pretty sure that when I showed you how to do this the first time, I had _name after $file1 and $file2


    PHP Code:
        $filename1 $headline."_1_".$time.substr($file1_namestrrpos($file1_name"."));
        
    $filename2 $headline."_2_".$time.substr($file2_namestrrpos($file2_name".")); 
    Read the manual on HTTP uploads.

    Also you need to add an uploads path in order to copy the file to its correct destination, and the folder must have write permissions for the web server.

    For instance if you wanted to store uploaded images in let's say a folder at this location

    /www/dotcommediainc/newssubmit/uploads

    You would need to do something like this.

    PHP Code:
    $upath '/www/dotcommediainc/newssubmit/uploads/';
        
    $filename1 $upath.$headline."_1_".$time.substr($file1_namestrrpos($file1_name"."));
        
    $filename2 $upath.$headline."_2_".$time.substr($file2_namestrrpos($file2_name".")); 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

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