Webforumz's RSS FeedRSS Webforumz RegistrationRegister Contact Webforumz StaffContact

Please help: Cannot view uploaded file

This is a discussion on "Please help: Cannot view uploaded file" within the PHP Forum section. This forum, and the thread "Please help: Cannot view uploaded file are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jun 25th, 2006, 03:10
New Member
Join Date: Jun 2006
Location: canada
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Please help: Cannot view uploaded file

I really appreciate & thank you very much for reading my question,here it comes.

Iam new to php & working with xampp on windows since i don have a linux system at the moment & have to get this assignment done asap.I have a problem viewing

the uploaded files in (html/htm & ppt ) format

Iam trying to upload files to a folder i created in Document root.Iam able to upload all the files into the folder,but cannot view them all.

Note: I used a software convertor to convert the excel file to htm format & then uploaded it.

#for the htm file i uploaded its stored as a firefox file into the uploaded folder. When i open the this file from the uploads folder i get a error "This

page uses

frames, but your browser doesn't support them"

I also tried to open the file with IE ,same result.

Is there a way to preserve the format as it was originally.

Now for the PPt File
=========================
# When i open the ppt file i uploaded it says "Powerpoint cannot open the type of file represented by c:\xampp\htdocs\uploads\test.ppt"

# After i upload an image i get " no preview available" when i try to open the image i uploaded.


*****but , i was able to upload & view a text file successfully from the uploads

folder **********

================================================== =

HTML CODE I USED TO BROWSE FILES & send it to storefile.php


html>

<body>
<h1>Upload filest</h1>
<form enctype="multipart/form-data" action="storefile.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
Upload this file: <input name="userfile" type="file">
<input type="submit" value="Send File">

</form>
</body>
</html>


================================================== =====


Here is the action code "storefile.php' i use to store the file in uploads folder

in document root



<html>
<head>
<title>Uploading File</title>
</head>

<body>

<?php


// $userfile is where file went on webserver
$userfile = $HTTP_POST_FILES['userfile']['tmp_name'];

// $userfile_name is original file names
$userfile_name = $HTTP_POST_FILES['userfile']['name'];

// $userfile_size is size in bytes
$userfile_size = $HTTP_POST_FILES['userfile']['size'];

// $userfile_type is mime type e.g. image/gif
$userfile_type = $HTTP_POST_FILES['userfile']['type'];

// $userfile_error is any error encountered
$userfile_error = $HTTP_POST_FILES['userfile']['error'];


// one more check: does the file have the right MIME type?

$userfile_type = 'ppt/html';


// put the file where we'd like it
$upfile = 'c:/xampp/htdocs/uploads/'.$userfile_name;

// is_uploaded_file and move_uploaded_file added at version 4.0.3
if (is_uploaded_file($userfile))
{
if (!move_uploaded_file($userfile, $upfile))
{
echo 'Problem: Could not move file to destination directory';
exit;
}
}
else
{
echo 'Problem: Possible file upload attack. Filename: '.$userfile_name;
exit;
}

echo 'File uploaded successfully!!<br /><br />';

// reformat the file contents
$fp = fopen($upfile, 'r');
$contents = fread ($fp, filesize ($upfile));
fclose ($fp);

$contents = strip_tags($contents);
$fp = fopen($upfile, 'w');
fwrite($fp, $contents);
fclose($fp);

?>
</body>

</html>



#### could u plese tell me ,where iam going wrong.

$If u can answer my question realtive to the linux system that is fine .

Thank u again for taking the time to read my question.

JAY
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old Jun 25th, 2006, 03:41
craig's Avatar
Reputable Member
Join Date: Sep 2005
Location: Preston, UK
Age: 22
Posts: 382
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Please help: Cannot view uploaded file

This may be just a shot in the dark...
Code: Select all
  $upfile = 'c:/xampp/htdocs/uploads/'.$userfile_name;
Are you doing this on your local comp or a server?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Jun 25th, 2006, 08:38
New Member
Join Date: Jun 2006
Location: canada
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Please help: Cannot view uploaded file

Thanks for the reply craig,

Iam testing the upload on my local computer.

so hence i made a folder in document root called uploads & uploaded the files.

The problem is iam able to upload the files to the local folder ,but cannot open the files from that folder.

***Text file can be uploaded& retrieved without any problems ***

I do not know what is the problem .I have also specified mime type of html/plain in the code


Any thoughts what can be wrong ????


Appreciate ur help

J
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Jun 26th, 2006, 20:53
Junior Member
Join Date: Jun 2006
Location: usa
Age: 30
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Please help: Cannot view uploaded file

hey, i am having same problem that u are having let me know if you can get to fix it...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Jun 27th, 2006, 10:31
Junior Member
Join Date: Jun 2006
Location: Sheffield, South Yorkshire, UK
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Please help: Cannot view uploaded file

PHP: Select all

 // reformat the file contents
   
$fp fopen($upfile'r');
   
$contents fread ($fpfilesize ($upfile));
   
fclose ($fp);
 
   
$contents strip_tags($contents);
   
$fp fopen($upfile'w');
   
fwrite($fp$contents);
   
fclose($fp); 
I think the reason you can't view your uploaded files is because they are getting corrupted by the above section of code.

Try placing a die(); after your successfull echo message, then upload a file you know you can currently open, make sure you have cleared out any previous uploads first just in case. Once the file has been uploaded test that you can open, I'm sure its the above block that is messing it up for you. Have you checked the permissions on the folder and the uploaded files?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
help, cannot, view, uploaded, file

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
my web page dosen't look the same once uploaded convert Starting Out 6 Jul 5th, 2007 13:46
Uploaded project but nothing plays! dharma Flash & Multimedia Forum 2 Sep 18th, 2006 01:25
image uploaded file overlap manzil PHP Forum 2 Aug 10th, 2006 13:48
altering uploaded files names Gurpreet82 Classic ASP 1 Mar 7th, 2006 02:26
Changes when uploaded pepe_starr Web Page Design 3 Mar 6th, 2006 22:33


All times are GMT. The time now is 16:06.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8