Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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

Posts: 28
Name: James
Trades: 0
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
 
 
Register now for full access!
Old 06-28-2008, 09:01 AM Re: Image gallery problem - funtions.php line 21
Junior Talker

Posts: 1
Name: stephen yabziz
Trades: 0
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
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
yabsoft is offline
Reply With Quote
View Public Profile
 
Old 06-28-2008, 08:59 PM Re: Image gallery problem - funtions.php line 21
Average Talker

Posts: 28
Name: James
Trades: 0
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, 11:16 PM Re: Image gallery problem - funtions.php line 21
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
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, 01:05 AM Re: Image gallery problem - funtions.php line 21
Average Talker

Posts: 28
Name: James
Trades: 0
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, 01:22 AM Re: Image gallery problem - funtions.php line 21
Extreme Talker

Posts: 238
Location: United States
Trades: 0
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, 04:03 PM Re: Image gallery problem - funtions.php line 21
Junior Talker

Posts: 3
Trades: 0
Hi

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

thanks
tulip
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
tulip178 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Image gallery problem - funtions.php line 21
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.46477 seconds with 12 queries