Advertisement

03.28.2008 at 06:34AM PDT, ID: 23277085
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

unlink() not deleting the file from the server.
I have this code in my php page. It does not delete the image file from the server. It always give the message "Couldn't delete file". No error in the pages.

                $fpath = $adminFrontendRoot."/teasers/uploaded_pics/".$rs['image_info'];
            //echo "fpath=".$fpath;
            if (! unlink ($fpath)) {
                echo ("Couldn't delete file");
               } else {
                echo ("Removed $fpath");
                }

What should be done so that the above code deletes the file from the folder.
Any help is appreciated.
Thanks.
Start your free trial to view this solution
Question Stats
Zone: Web Development
Question Asked By: cyberwebservice
Solution Provided By: amigura
Participating Experts: 4
Solution Grade: A
Views: 0
Translate:
Loading Advertisement...
03.28.2008 at 06:59AM PDT, ID: 21230411

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 06:59AM PDT, ID: 21230415

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 07:18AM PDT, ID: 21230583

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 07:19AM PDT, ID: 21230596

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 07:21AM PDT, ID: 21230620

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 07:24AM PDT, ID: 21230650

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 07:25AM PDT, ID: 21230661

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 07:35AM PDT, ID: 21230777

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 07:51AM PDT, ID: 21230925

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 07:53AM PDT, ID: 21230941

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 07:54AM PDT, ID: 21230958

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 08:12AM PDT, ID: 21231113

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 08:14AM PDT, ID: 21231141

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 08:42AM PDT, ID: 21231385

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 09:02AM PDT, ID: 21231584

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 09:12AM PDT, ID: 21231695

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 09:14AM PDT, ID: 21231708

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 09:17AM PDT, ID: 21231744

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 09:18AM PDT, ID: 21231747

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 09:21AM PDT, ID: 21231782

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 09:32AM PDT, ID: 21231867

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 09:38AM PDT, ID: 21231923

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 09:54AM PDT, ID: 21232069

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 03:05PM PDT, ID: 21234442

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 08:15PM PDT, ID: 21235395

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 09:00PM PDT, ID: 21235478

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
03.28.2008 at 06:59AM PDT, ID: 21230411

Rank: Master

Are you sure that the directory has the permissions set up to allow read/write privileges?

To test that, you can use:

if(is_writeable($fpath) {
     echo "File is writeable";
} else {
     echo "File is not writeable";
}
Assisted Solution
 
03.28.2008 at 06:59AM PDT, ID: 21230415

Rank: Master

Forgot a closing parentheses, correction:

if(is_writeable($fpath)) {
     echo "File is writeable";
} else {
     echo "File is not writeable";
}
 
03.28.2008 at 07:18AM PDT, ID: 21230583
It can also depend on the server you are using. I have encountered similar problems where the native unlink command just doesn't work on certain servers.

exec() and system() are ways to directly execute OS commands. You have to know which operating system you are on. If it's a windows server, you can try something like

exec("del " . $fpath);

If it's unix, try:

exec("rm " . $fpath);

Hope this helps.

Tom
 
03.28.2008 at 07:19AM PDT, ID: 21230596
Thanks for the reply.

it says, "File is not writeable"
 
03.28.2008 at 07:21AM PDT, ID: 21230620
Do you have access to the server? Can you get to that directory using your FTP software?

If so, use your FTP software and navigate to that folder. Right-click on the folder and choose "Settings..." or "Permissions..." or "Access..." (depending on your FTP software). You should see the read/write permissions for that folder. Make sure "write" is turned on for all three groups.

If you need a command-line solution, let us know.
 
03.28.2008 at 07:24AM PDT, ID: 21230650
I'm using unix server.
I tried exec("rm " . $fpath); but didn't work.

I checked the Ftp folder, the write permission is given only for 'owner'.
 
03.28.2008 at 07:25AM PDT, ID: 21230661
What should i do to change the permissions?
 
03.28.2008 at 07:35AM PDT, ID: 21230777
Okay, what FTP software are you using? Or do you use Telnet to access your server?
 
03.28.2008 at 07:51AM PDT, ID: 21230925

Rank: Master

You need to either chmod your file to 777 (which is kind of insecure) or give apache read/write permissions.  I think tomaugerdotcom is trying to get your specific info to help you along those lines.  If you have a managed server, you could have the admins set apache up to give you read/write permissions and then php has permissions to access files (read, write, execute, etc.).
 
03.28.2008 at 07:53AM PDT, ID: 21230941

Rank: Master

If that's your setup, Apache is sometimes user: nobody.  My server had this problem and I simply had to modify the setup to give read/write/execute permissions to user: nobody and then all the file functions in php worked wonderfully.
 
03.28.2008 at 07:54AM PDT, ID: 21230958
I was thinking just enable read/write for that specific folder only. That minimized the security risk somewhat.
 
03.28.2008 at 08:12AM PDT, ID: 21231113
It definitely sounds like a permissions issue.

Before you run unlink on the file, first run chmod() and give it permissions of 777. You may also need to chown() it as well to give your script ownership.
 
03.28.2008 at 08:14AM PDT, ID: 21231141
I don't have any direct access to the server.
I'm working on my client' website and he has given me the ftp details to upload/download the files from his shared hosting server.

I am not using any FTP software, i am using IE browser right now. I have smartFTP installed in my computer, but not using it now.

what will be the risks involved if i chmod that image folder ?
thanks for the help so far.
 
03.28.2008 at 08:42AM PDT, ID: 21231385
Here's a quick tut on SmartFTP chmod:
http://www.siteground.com/tutorials/ftp/ftp_chmod.htm

I personally think the risks are quite minimal, especially if you make the directory (teasers/uploaded_pics) name a little more obscure (teasers/ulpic) for example. The likelihood of that one folder being exposed to any kind of malicious attack is minimal IMO, but rowejd may have more to say on that matter specifically.
 
03.28.2008 at 09:02AM PDT, ID: 21231584
Well you shouldn't need to chmod the whole folder. Just have your script chmod the specific file before deleting it with unlink. Here is an example:

[code]
$file = "/images/some_image.jpg";

chmod($file, 777);

$delete = unlink($file);

if(!$delete)
{
     echo "File not deleted";
}
else
{
     echo "File deleted";
}
[/code]
Assisted Solution
 
03.28.2008 at 09:12AM PDT, ID: 21231695
I am getting "File not deleted" if i use chmod($fpath, 777)
 
03.28.2008 at 09:14AM PDT, ID: 21231708
Echo out the file path to make sure it is correct.

You may need to change it to the absolute path.
 
03.28.2008 at 09:17AM PDT, ID: 21231744
The file path shows the absolute path...but not the physical path. This is the path it shows:
http://mywebsite/adminpanel/teasers/uploaded_pics/fl-6b.jpg


 
03.28.2008 at 09:18AM PDT, ID: 21231747
Now, i will try to CHMOD using command prompt.
 
03.28.2008 at 09:21AM PDT, ID: 21231782
CHMOD was successful, but still the file not getting deleted.
 
03.28.2008 at 09:32AM PDT, ID: 21231867
Are you sure your webserver is Apache on a Unix box? Otherwise, the whole chmod thing won't do the trick...
 
03.28.2008 at 09:38AM PDT, ID: 21231923
Hey, have we determined that the path is correct? I mean, you should perhaps just test it to be sure that we're not barking up the wrong tree here. Try:

if (file_exists($fpath)) {
    unlink($fpath);
}  else {
   echo "File does not exist at this location";
}
Assisted Solution
 
03.28.2008 at 09:54AM PDT, ID: 21232069
I have also read that the folder you are deleting the file FROM also needs to have its permissions set to x7x

T
 
03.28.2008 at 03:05PM PDT, ID: 21234442
you need to keep folder to 755 minimum or you will be in trouble from hackers.

i'm guessing this your problem, need to be phy

"The file path shows the absolute path...but not the physical path. This is the path it shows:
http://mywebsite/adminpanel/teasers/uploaded_pics/fl-6b.jpg "


echo dirname($_SERVER['SCRIPT_FILENAME']); // to get physical path

e.g.  /home/mysite/public_html/adminpanel/teasers/uploaded_pics/fl-6b.jpg


Accepted Solution
 
03.28.2008 at 08:15PM PDT, ID: 21235395
sorry i forgot to mention, the file is not in the main domain, it is in the subdomain.

when i echo i get this:
fpath=http://xyz.mywebsite.com/adminpanel/teasers/uploaded_pics/fl-6b.jpg
File is not writeable
File does not exist at this location
Couldn't delete file

I checked the folder name, everything is correct, the file is located in this path, but it says, 'File does not exist at this location'.

I will try the physical path now and update you with the results.
 
03.28.2008 at 09:00PM PDT, ID: 21235478
The image gets deleted when i give the physical path for unlink().

Thanks for the help :)

I would like to split the points.
 
 
20080236-EE-VQP-29 / EE_QW_EXPERT_20070906