Jump to content

PHP Upload Script


pinacoladaxb

Recommended Posts

This thread is somewhat of a continuation from Fairly Basic PHP Question, but since it is no longer a basic question and I have new information on the topic, I created a new thread.

 

To recap, I am making a game. In the game, the user stores data (more specifically, custom levels) on my web server. The reason for this is that since this is a web application, I cannot write data to the user's disk. Plus, the user can now play the game from any computer. The program that I am using to make this game is Multimedia Fusion 2, which is a program that advertises "no programming skills required to make games." Of course, programming skill is very useful when doing things like I am trying to do. Rather than typing code, you use an events editor that allows you to do if-then statements without actually programming. The way this is done is with "extensions," which are scripts that handle much of the programming for you. To upload files, I am using the MooSock script. I think that's enough to get you more than caught up.

 

The problem that I am having is that the files I try to upload are not uploaded. Plain and simple. My goal is to find out why, and then fix it. Prepare yourself for a ton of information.....

 

Here's what my "code" looks like right now for the game. If you know php and html, you should be able to interpret it:



  • MooSock: Connect to http://www.flufferfluff.com on port 80
  • MooSock: Send Text Line "POST /games/battles/upload.php HTTP/1.1"
  • MooSock: Send Text Line "Host: http://www.flufferfluff.com"
  • MooSock: Send Text Line "Content-type: multipart/form-data, boundary=AaB03x@:&%CCCds"
  • MooSock: Send Text Line "Content-length: "+Str$(Len("--AaB03x@:&%CCCds")+Len("--AaB03x@:&%CCCds--")+Len(string$( "String Content-Disposition" ))+Len("Content-type: application/octet-stream")+6*2+Sizeof( "File", Edittext$( "Edit File" )))

    The above line just sends the total size of everything. This includes the size of the file and the size of the text being sent from this code.

  • MooSock: Send Text Line "";
  • MooSock: Send Text Line "--AaB03x@:&%CCCds";
  • MooSock: Send Text Line "content-disposition: form-data; name=""""image"""";
  • filename=""""name_of_file.bmp"""";
  • MooSock: Send Text Line "Content-type: application/octet-stream";
  • MooSock: Send Text Line "";
  • MooSock: Send Bianary "C:\Documents and Settings\Laima\My Documents\name_of_file.bmp";
  • MooSock: Send Text Line "";
  • MooSock: Send Text Line "--AaB03x@:&%CCCds--";
     

Here's the php file "upload.php" that the code sends the file to:

<?php

$first_target_path = "images/";
$target_path = $first_target_path . basename( $_FILES['image']['name']);
$_FILES['image']['tmp_name'];

?>

And here's what the server sends back:

HTTP/1.1 200 OK

Date: Fri, 30 May 2008 21:34:47 GMT

Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8g DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635

X-Powered-By: PHP/5.2.6

Content-Length: 0

Content-Type: text/html

Sorry if this is an overkill of information, but I figure I should tell you everything if we are to debug this. If you think you may know what's wrong, even if you are not sure, could you please share it? I have been working to solve this simple problem for about a month now. I'm tired. I really hope we can fix the problem in just a couple days.

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/108071-php-upload-script/
Share on other sites

Hmm. I've never heard of a friendly bump before. I'll have to try it.

 

To those of you actually reading this, I would appreciate you telling me why you aren't replying. Was anything too vague or just too complex?

 

i see 3 lines of PHP which don't seem to have a problem. the rest is Greek. any chance this misspelling is a problem?

 

Send Bianary

 

Link to comment
https://forums.phpfreaks.com/topic/108071-php-upload-script/#findComment-554334
Share on other sites

OK. It was a typo in the post, but not in the code. Like I said, it's not a language you would understand. I was hoping you'd be able to interpret it based on my explanation. All it does is send several lines of text to the php file, and then a binary file.

Link to comment
https://forums.phpfreaks.com/topic/108071-php-upload-script/#findComment-554362
Share on other sites

Hmm. I've never heard of a friendly bump before. I'll have to try it.

 

To those of you actually reading this, I would appreciate you telling me why you aren't replying. Was anything too vague or just too complex?

 

friendly bump is something that people do to bump other peoples threads if they see that their thread is not being responded or being left out, k thanks...

Link to comment
https://forums.phpfreaks.com/topic/108071-php-upload-script/#findComment-555301
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.