Reply
Image gallery problem - funtions.php line 21
Old 06-28-2008, 03:29 AM Image gallery problem - funtions.php line 21
Average Talker

Posts: 28
Name: James
Hi,
i followed a tutorial on how to create a image gallery with a admin panel, and when i tried to upload a image, it gave me this error:

Warning: move_uploaded_file(C:/webroot/gallery/images/gallery/c1b55bfadb00c4304fb9f774eefafb93.png) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\xampplite\htdocs\php\cms\library\functions.php on line 21

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampplite\tmp\php22F.tmp' to 'C:/webroot/gallery/images/gallery/c1b55bfadb00c4304fb9f774eefafb93.png' in C:\xampplite\htdocs\php\cms\library\functions.php on line 21
Error uploading file

line 21 on functions.php is part of a function to upload the images:
Code:
function uploadImage($inputName, $uploadDir)
{
    $image     = $_FILES[$inputName];
    $imagePath = '';
    $thumbnailPath = '';
    
    if (trim($image['tmp_name']) != '') {
        $ext = substr(strrchr($image['name'], "."), 1); 

        $imagePath = md5(rand() * time()) . ".$ext";
        $result    = move_uploaded_file($image['tmp_name'], $uploadDir . $imagePath);
            
        if ($result) {
            $thumbnailPath =  md5(rand() * time()) . ".$ext";
            $result = createThumbnail($uploadDir . $imagePath, $uploadDir . 'thumbnail/' . $thumbnailPath, THUMBNAIL_WIDTH);
            
            if (!$result) {
                unlink($uploadDir . $imagePath);
                $imagePath = $thumbnailPath = '';
            } else {
                $thumbnailPath = $result;
            }    
        } else {

            $imagePath = $thumbnailPath = '';
        }
        
    }

Can someone please explain what is going on?

thanks,
4o4
4o4found is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 06-28-2008, 08:01 AM Re: Image gallery problem - funtions.php line 21
Junior Talker

Posts: 1
Name: stephen yabziz
Does the C:/webroot/gallery/images/gallery/ exist on your server? If it exists there, the directory can be written in(i.e.: chmoding to 0777)?

From the script, you can define the image directory path by them:
$uploadDir and $imagePath

Quote:
Originally Posted by 4o4found View Post
Hi,
i followed a tutorial on how to create a image gallery with a admin panel, and when i tried to upload a image, it gave me this error:

Warning: move_uploaded_file(C:/webroot/gallery/images/gallery/c1b55bfadb00c4304fb9f774eefafb93.png) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\xampplite\htdocs\php\cms\library\functions.php on line 21

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampplite\tmp\php22F.tmp' to 'C:/webroot/gallery/images/gallery/c1b55bfadb00c4304fb9f774eefafb93.png' in C:\xampplite\htdocs\php\cms\library\functions.php on line 21
Error uploading file

line 21 on functions.php is part of a function to upload the images:
Code:
function uploadImage($inputName, $uploadDir)
{
    $image     = $_FILES[$inputName];
    $imagePath = '';
    $thumbnailPath = '';
 
    if (trim($image['tmp_name']) != '') {
        $ext = substr(strrchr($image['name'], "."), 1); 
 
        $imagePath = md5(rand() * time()) . ".$ext";
        $result    = move_uploaded_file($image['tmp_name'], $uploadDir . $imagePath);
 
        if ($result) {
            $thumbnailPath =  md5(rand() * time()) . ".$ext";
            $result = createThumbnail($uploadDir . $imagePath, $uploadDir . 'thumbnail/' . $thumbnailPath, THUMBNAIL_WIDTH);
 
            if (!$result) {
                unlink($uploadDir . $imagePath);
                $imagePath = $thumbnailPath = '';
            } else {
                $thumbnailPath = $result;
            }    
        } else {
 
            $imagePath = $thumbnailPath = '';
        }
 
    }

Can someone please explain what is going on?

thanks,
4o4
yabsoft is offline
Reply With Quote
View Public Profile
 
Old 06-28-2008, 07:59 PM Re: Image gallery problem - funtions.php line 21
Average Talker

Posts: 28
Name: James
Okay thanks i see what is going on.
but one more question:
I am running this as a test on my xampplite instalation.
How can i chmod the folders in localhost?
4o4found is offline
Reply With Quote
View Public Profile
 
Old 06-28-2008, 10:16 PM Re: Image gallery problem - funtions.php line 21
mgraphic's Avatar
Truth Seeker

Posts: 2,311
Name: Keith Marshall
Location: West Hartford, CT
Quote:
Originally Posted by 4o4found View Post
Okay thanks i see what is going on.
but one more question:
I am running this as a test on my xampplite instalation.
How can i chmod the folders in localhost?
CHMOD does not work on a Windows plateform
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 06-29-2008, 12:05 AM Re: Image gallery problem - funtions.php line 21
Average Talker

Posts: 28
Name: James
so there is no way i can CHMOD with xampp?
I have filezilla server installed with this, dosent this mean i can do it?
4o4found is offline
Reply With Quote
View Public Profile
 
Old 06-29-2008, 12:22 AM Re: Image gallery problem - funtions.php line 21
Extreme Talker

Posts: 235
Location: United States
Windows doesn't need chmod. You can set permissions and read-only on files, but by default, you don't need to change anything. Basically, the equivalent of "chmod to 0777" on Windows is "make sure the file or folder exists"
frost is offline
Reply With Quote
View Public Profile
 
Old 06-30-2008, 03:03 PM Re: Image gallery problem - funtions.php line 21
Junior Talker

Posts: 3
Hi

i was planning to integrate an image gallery in my site as well. this information is helpful

thanks
tulip
__________________
upvc windows Online Fruit Machines
tulip178 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Image gallery problem - funtions.php line 21
 

Thread Tools

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

vB 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.17794 seconds with 13 queries