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
Need help with a certain php script
Old 03-11-2008, 05:31 AM Need help with a certain php script
Novice Talker

Posts: 13
Trades: 0
Hi

I need urgent help on a particular script written by hjsplit. It splits files online.... however its not working for me... I always provide the right path but its says that cannot read file, similarly on the write location i have changed the permission but it says that write permission is not granted. Please help me out with this script.

Here's the script ...

Code:
 
<?php
/*
 --------------------------------------------------
 filesplit.php HJSplit compatiple PHP file splitter
 --------------------------------------------------
 
 File name: 
 filesplit.php                
 Author: 
 Umit Tirpan 2007-03-22          
 Author's Website: 
 http://forum.iyinet.com/
 Description:
 This PHP script, splits the files into smaller pieces in binary.
 It is compatiple with HJSplit, so you can re-join splitted files using HJSplit's Join utility.
 It can split a file up to 999 pieces.
 What is the use, why will I use this?
 Some webmasters do not have shell access to their websites. This prevents them splitting big files, ie. MySQL backups, into smaller files. Splitting a 200Mb file into 10 x 20Mb file may be easy on webmaster to download in pieces. 
 
 How to run:
 Make sure your webserver has write permission on the target folder.
 Edit variables. 
 Upload (ftp) this file to your webserver.
 For security reason, filename is hardcoded. You can modify code to accept $_GET['file']
 Run with your favorite browser.
  http://www.<your-web-site>.com/filesplit.php
 It is Ok to modify this code and use in/with your applications.
 */
 

// Edit here (3 variables)
// ---------------------------
// File to split, is its not in the same folder with filesplit.php, full path is required.
$file = "my-big-file.zip"; 
// Target folder. Splitted files will be stored here. Original file never gets touched.
// Do not append slash! Make sure webserver has write permission on this folder.
$targetfolder = '/tmp';
// File size in Mb per piece. For a 200Mb file if piecesize=10 it will result with 20 x 10Mb files
$piecesize = 10;
 
// Do NOT edit under this line
// ---------------------------
$buffer = 1024*8;
$piece = 1048576*$piecesize;
$current = 0;
$splitnum = 1;
if(!$handle = fopen($file, "rb")) {
 die("Unable to open $file.<br>Make sure you edited filesplit.php correctly!<br>\n");
}
$piece_name = $targetfolder.'/'.$file.'.'.str_pad($splitnum, 3, "0", STR_PAD_LEFT);
$fw = fopen($piece_name,"w");
echo "Splitting $file into $piecesize Mb files (last piece may be smaller in size) ...<br>\n";
echo "$piece_name <br>\n";
while (!feof($handle)) {
 if($current < $piece) {
  if(fwrite($fw, fread($handle, $buffer))) {
   $current += $buffer;
  } else {
   die("filesplit.php is unable to write to current folder.<br>I think it does not have write permission!<br>Try chmod +w folder<br>\n");
  }
 } else {
  fclose($fw);
  $current = 0;
  $splitnum++;
  $piece_name = $targetfolder.'/'.$file.'.'.str_pad($splitnum, 3, "0", STR_PAD_LEFT);
  echo "$piece_name <br>\n";
  $fw = fopen($piece_name,"w");
 }
}
fclose($fw);
fclose($handle);
echo "Done! <br>\n"
?>
Thanks in Advance
Desi-Instincts is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-11-2008, 05:34 AM Re: Need help with a certain php script
Super Spam Talker

Latest Blog Post:
PSD Squirrel Launched
Posts: 932
Trades: 7
the permissions of the file.. what did you change them to? 755?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Sir P is offline
Reply With Quote
View Public Profile Visit Sir P's homepage!
 
Old 03-11-2008, 06:29 AM Re: Need help with a certain php script
Novice Talker

Posts: 13
Trades: 0
permission of which file the source file which is to be splitted ??

Its 644 at the moment.

and of the destination folder "tmp" its 777
Desi-Instincts is offline
Reply With Quote
View Public Profile
 
Old 03-11-2008, 06:36 AM Re: Need help with a certain php script
Super Spam Talker

Latest Blog Post:
PSD Squirrel Launched
Posts: 932
Trades: 7
well try changing the file to 777.. and the tmp dir to 777..... make sure its the file not just the dir..
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Sir P is offline
Reply With Quote
View Public Profile Visit Sir P's homepage!
 
Reply     « Reply to Need help with a certain php script
 

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