Skip navigation
Currently Being Moderated

Uploading files using Zend Framework

Nov 2, 2010 2:45 PM

I am tyring to use the Zend Framework to upload files as outlined in the "Adobe Dreamweaver CS5 with PHP" book by David Powers.  I've been using the example code (more or less), and can get it to work perfectly with a local XAMPP installation of Apache and PHP.  Howver, I can't get it to work successfully with a hosted site, having tried both GoDaddy and Verio.

 

The Zend Framework is correctly installed, include paths set correctly (I know this because other Zend FW operations, such as validation work fine).  In addition, if the directory I want to upload to isn't correctly specified I get errors on that.  But when I try to actually upload a file (again, with code that works on the XAMPP platform), I get nothing.  No errors, and no uploaded file.

 

I have the script set up to send an email with a link to the uploaded file, and the name field is blank (but the email does get sent, again indicating that the ZF is working).  I'm concluding I have something incorrectly configured on the hosting plaforms, and am looking for suggestions as what to look at.  Thanks.

 

BTW, checked the permissions on the upload directory, and it should be writeable...

 
Replies
  • Currently Being Moderated
    Nov 5, 2010 10:13 AM   in reply to antares5

    Have you checked the configuration on the remote server? Is file_uploads On?

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 6, 2010 8:28 AM   in reply to antares5

    antares5 wrote:

     

    Also, I note that my hosting providers only support PHP 5.2.14, whereas on my XAMPP installation I'm using 5.3  Could that be an issue?

    No. Zend Framework 1.x works with PHP 5.2.

     

    Try the following:

     

    $destination = 'C:/upload_test';  // set to correct location
    $uploader = new Zend_File_Transfer_Adapter_Http();
    $uploader->setDestination($destination);
    if (!$uploader->receive()) {
      $messages = $uploader->getMessages();
      print_r($messages);
    }
    
     
    |
    Mark as:
  • Currently Being Moderated
    Nov 8, 2010 3:47 PM   in reply to antares5

    No problems. It's a mistake we've all made at one time or another. Glad you find the book useful.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 18, 2012 9:41 AM   in reply to David_Powers

    David, It looks that its been a couple of years since someone posted to this site. I'm using your new book DW CS5 and I'm trying to implement the Zend_File_Transfer_Adapter_Http() for an upload page on a site that I'm creating. When I try to view my upload.php page I'm getting the following error.

     

    Fatal error:  Uncaught exception 'Zend_File_Transfer_Exception' with message 'The given destination is not a directory or does not exist' in C:\xampp\htdocs\php_Library\library\Zend\File\Transfer\Adapter\Abstra ct.php:1035 Stack trace: #0 C:\xampp\htdocs\rawflow\process_upload.php(12): Zend_File_Transfer_Adapter_Abstract->setDestination(NULL) #1 C:\xampp\htdocs\rawflow\upload.html(6): require_once('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\php_Library\library\Zend\File\Transfer\Adapter\Abstrac t.php on line 1035.

     

    I can navigate to the file through windows explorer, so I'm not sure why I'm getting a does not exist error.

     

    Any thoughts on what I possibly missed when setting up my instance?

     

    I'm really enjoying the book and have found it to be a great resource as I build my first dynamic site from the ground up.

     

    Thanks,

    J

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 21, 2012 7:09 PM   in reply to jtolbert0823

    I fixed this error, it was pretty simple once I figured it out. My process_upload.php was not in the correct folder.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 23, 2013 10:26 AM   in reply to jtolbert0823

    Hello, mister David!

    I can't solve  a problem in the same book. I try to build a travel website like in your book. In lesson 10, we learn to upload images. My images are uploaded, but on the root of the site like that: /home/content/56/10647856/html/image_uploadjoshuatree2.jpg uploaded successfully

    I set $destination = '/home/content/56/10647856/html/image_upload/';

    in db_definitrions.php and in Abstract.php in zend lib in line 947

    the site is hosted by godaddy. I know is not the best place to host, I encounter a lot of errors during the learnig process, but I think is good to leran from errors

     

    I like your books!

    Thanks!

    Liviu Stanescu

    Romania

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 23, 2013 10:43 AM   in reply to pyratek

    I'm sorry, right in the moment when I click "post" I undersand where is MY ERROR, I modified Abstract file because of another error with a missing directory for upload, but I did not fix that error when I change the path, I fix it on godaddy setup on file extension! Sorry .

    That the NLP's writers start with "take a peace of paper and write down your problem" or a keyboard!

    Sorry!

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 23, 2013 11:21 AM   in reply to pyratek

    opps... now I have uploaded img in corect dir, with corect name, probaly changing the code in a wrog place, again inevitably direct me to another error, I can't see imgs in edit, list, delete, places and photos

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 23, 2013 11:47 AM   in reply to pyratek

    my stuppid again! I forget of course to say my site is not in the root, is a subdomain

    the fix was: /image_upload/ instead image_upload/ in img src= code in all files.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points