LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 08-09-2009, 02:19 AM   #1
jitender.ind
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Rep: Reputation: 0
Unhappy Uploaded file using PHP scripts are getting deleted of it's own


Hi,

I'm having a very strange problem. I use lampp on centOS linux. My application has a upload Script (in PHP) which uploads file to file system. after upload and moving file to correct location, uploaded files are getting deleted. I check file upload and moving of file by putting all the status in a text log file. files are getting uploaded properly and after upload I'm able to move the files to it's correct location.

thanks,
Jitender Aryan
 
Old 08-09-2009, 07:36 PM   #2
jrtayloriv
Member
 
Registered: Jun 2004
Location: Inland NW, US
Distribution: Ubuntu
Posts: 365
Blog Entries: 1

Rep: Reputation: 44
It will be hard for anyone to tell you what is wrong with your script if you don't show it to them. Please post a copy of the code that is not working.
 
Old 08-10-2009, 12:59 AM   #3
jitender.ind
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Please see the file attached to see the code I used for uploading.

thanks,
Jitender Aryan
Attached Files
File Type: txt uploadCode.txt (5.1 KB, 4 views)
 
Old 08-10-2009, 01:26 PM   #4
jrtayloriv
Member
 
Registered: Jun 2004
Location: Inland NW, US
Distribution: Ubuntu
Posts: 365
Blog Entries: 1

Rep: Reputation: 44
First, you should break up that huge set of nested if statements into a set of functions so that your code is more readable.

For example, the section that reads:

Code:
//update owners stats
$URL = DB_SCRIPT_PATH . "ownerUpdate.php?ownerId=" . $ownerId;
fwrite($fp,"\t [$fileId]URL for upading Owner Stats: ".$URL." - ".date('Y-m-d H:i:s')." \n");
$cURLHandler = curl_init ();
curl_setopt ( $cURLHandler, CURLOPT_URL, $URL );
curl_exec ( $cURLHandler );
fwrite($fp,"\t [$fileId] Result From Owner Stat Update Script : ".$result." - ".date('Y-m-d H:i:s')." \n");
					
$URL = DB_SCRIPT_PATH . "datafile.php?action=update&uploadStatus=0filePath=m/s/".$songId."/f/".$fileId."/".$name."&fileType=" . $_FILES ['uploadfile'] ['type'] . "&fileExtension=" . $extn."&fileId=".$fileId;
fwrite($fp,"\t [$fileId]URL for upading file Stats: ".$URL." \n");
$cURLHandler = curl_init ();
curl_setopt ( $cURLHandler, CURLOPT_URL, $URL );
curl_exec ( $cURLHandler );
fwrite($fp,"\t [$fileId]Result From File Stat Update Script : ".$result." - ".date('Y-m-d H:i:s')." \n");
Could be broken off into its own function 'update_owner_stats()'.

And the section:
Code:
//request for jox to create files
$URL =SERVER_PHP_PATH." ".MIXER_SCRIPT_PATH . "joxCommandCLI.php " . $songId . " " . $fileId . " " . $extn;
fwrite($fp,"\t [$fileId]URL for Jox Request: ".$URL." - ".date('Y-m-d H:i:s')." \n");
exec($URL);
fwrite($fp,"\t [$fileId]End Time: ".date('Y-m-d H:i:s')." \n \n \n");
Could be broken off into a function called 'jox_create_file()'.

Doing this will make your program easier for you to understand (as well as for anyone else who is reading your code), and thus will make it easier for you to debug and discover/fix the problem(s) with it.

In general, whenever you've got an big set of nested if statements, like the one in the code you posted, you should see if you can break up your logic into seperate functions somehow. You can't always do so (sometimes you actually need a big nested if statement, but it is very often a hint that you should break it up into smaller functions.

Once you've done this, if it is still not working (i.e. if you don't just discover the problem in the process of refactoring it), then post up the new code.

--jrtayloriv

Last edited by jrtayloriv; 08-10-2009 at 01:31 PM.
 
  


Reply


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload file to ftp server -vsftp- but can not delete or change the file once uploaded murattas6 Linux - Server 2 06-26-2009 06:00 AM
Uploaded files from PHP app are dissapearing on new ubuntu server rgman Linux - Server 4 04-01-2009 02:47 AM
PHP validation of uploaded WAV file Spudley Programming 1 12-16-2008 05:27 PM
get full path of uploaded file in php spoody_goon Programming 2 05-10-2005 07:32 PM
uploaded file on vsftpd has wrong file attributes rune.kg Linux - Newbie 2 03-06-2004 09:23 AM


All times are GMT -5. The time now is 07:57 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration